Python multiprocessing: synchronizing file-like object

前端 未结 2 596
日久生厌
日久生厌 2021-02-09 08:12

I\'m trying to make a file like object which is meant to be assigned to sys.stdout/sys.stderr during testing to provide deterministic output. It\'s not meant to be fast, just re

2条回答
  •  野性不改
    2021-02-09 08:50

    I have encountered far fewer multiprocessing bugs with Python 2.7 than with Python 2.6. Having said this, the solution I used to avoid the "Exception in thread QueueFeederThread" problem is to sleep momentarily, possibly for 0.01s, in each process in which the the Queue is used. It is true that using sleep is not desirable or even reliable, but the specified duration was observed to work sufficiently well in practice for me. You can also try 0.1s.

提交回复
热议问题