Write data to disk in Python as a background process

前端 未结 3 902
礼貌的吻别
礼貌的吻别 2021-02-04 17:59

I have a program in Python that basically does the following:

for j in xrange(200):
    # 1) Compute a bunch of data
    # 2) Write data to disk
<
3条回答
  •  醉梦人生
    2021-02-04 18:22

    You can use something such as Queue.Queue (the module is here: Queue) and threading.Thread (or threading.start_new_thread if you just want a function), the module is here: threading - As a file write is not CPU intensive and use more IO. (and the GIL doesn't affect it).

提交回复
热议问题