Hangs in multiprocessing
See original GitHub issueThis test case hangs in Django 2.0 (works without freeze_time)-
from multiprocessing import Pool
from freezegun import freeze_time
from django.test import TestCase
@freeze_time("2018-02-14 11:00:00")
class MultiProcessingTestCase(TestCase):
"""
Test case to test if pool process of multiprocessing works
"""
def test_multi_processing(self):
print("POOLING")
with Pool(processes=2) as pool:
pass
print("DONE")
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Handling Hang in Python Multiprocessing - Sefik Ilkin Serengil
I used apply_async method of multiprocessing.pool module to handle the deadlock problem. I stored the response of the apply_async method in a ...
Read more >python multiprocessing - process hangs on join for large queue
When I loop over 10,000 or more, my script hangs on worker.join() . It works fine when the loop only goes to 1,000....
Read more >Why your multiprocessing Pool is stuck (it's full of sharks!)
On Linux, the default configuration of Python's multiprocessing library can lead to deadlocks and brokenness. Learn why, and how to fix it.
Read more >Code using multiprocessing hangs indefinitely on iPython 8+ if ...
When using pool.map from the multiprocessing library on iPython 8.0.0 and higher, an exception in one of the workers will cause the process ......
Read more >Program hangs in debug when multiprocessing process starts ...
When starting a multiprocessing process and then that process starts another process, the program will get locked when run in debugger. Following simple...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m seeing similar behaviour after upgrading
freezegun
from1.0.0
to1.1.0
.This code snippet reproduces the issue:
If I downgrade
freezegun
from1.1.0
to1.0.0
the hang does not happen. Using the workaround mentioned by boxed in this comment solves the issue. Another workaround is to supplytick=True
tofreeze_time
.I am using Python
3.9.1
.Contents of
requirements.txt
:I got it to stop hanging on
join()
withextend_ignore_list
and addingmultiprocessing
to that. Sadly, that means that since my UUT is in another process from the test bench, applying thetick()
doesn’t affect the copy that got spun off, so looks like I can’t usefreezegun
for this right now.I suspect this is also the cause of #359 - unless
freezegun
implements some kind of multiprocessing manager/namespace to share its state between processes, it’s not gonna work. That’s what my workaround was, but then I had to add the hooks to my class to explicitly call my time synchronization object, which sucks.