pytest icon indicating copy to clipboard operation
pytest copied to clipboard

pytest hang when run with multiprocessing

Open zdyj3170101136 opened this issue 1 year ago • 1 comments

code:

import os
import multiprocessing
import gevent.monkey
gevent.monkey.patch_all()
import threading

class EventThread(threading.Thread):
    def __init__(self, event=multiprocessing.Event()):
        super(EventThread, self).__init__()
        self.daemon = True
        self.event= event
        #forksafe.register(self._restart_on_fork)

    def _restart_on_fork(self):
        new_thread = EventThread(self.event)
        new_thread.start()

    def run(self):
        while self.event.wait():
            print("hello")

print("a")
def test_a():
   pid = os.fork()
   t = EventThread()
   t.start()

zdyj3170101136 avatar Feb 04 '24 05:02 zdyj3170101136

There's probably too much here for anyone to deal with -- gevent, forks, daemon threads, multiprocessing, events, global variables...

bluetech avatar Feb 17 '24 10:02 bluetech

This issue is stale because it has been open for 14 days with no activity.

github-actions[bot] avatar Mar 03 '24 01:03 github-actions[bot]

This issue was closed because it has been inactive for 7 days since being marked as stale.

github-actions[bot] avatar Mar 10 '24 01:03 github-actions[bot]