I'm working on a complex application involving multiple sockets and threads/processes. For some reason, sometimes this particular process won't run unless a delay was invoked.
Something like:
class MyClass:
def somefunc(self):
some_thread = Thread(...) # Some complex processing.
some_thread.start()
time.sleep(1) # Some delay like this is needed.
some_process = Process(target=sometarget)
print('Should start')
some_process.start()
print('Should have started')
def sometarget(self):
print('It started')
# Do more complex processing here.
This prints out something like:
Should start
Should have started
It started # This gets printed out only if there's a significant delay inserted
Not sure if it's just some random occurrence due to how Python schedules jobs underneath, but if I don't put a delay, it doesn't seem to run even after I wait a while.