- Python Home
- About
- News
- Documentation
- Downloads
- Community
- Foundation
- Developer's Guide
- Issue Tracker
- Issues
- Summaries
- User
- Administration
- Help
➜
This issue tracker has been migrated to GitHub,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
| Author | Arkady M |
|---|---|
| Recipients | Arkady M, davin, pitrou |
| Date | 2020-06-10.12:13:49 |
| SpamBayes Score | -1.0 |
| Marked as misclassified | Yes |
| Message-id | <1591791229.94.0.657635762104.issue40860@roundup.psfhosted.org> |
| In-reply-to |
| Content |
|---|
A workaround is to synchronize the call to Process.start()
diff --git a/main.py b/main.py
index d09dc53..49d68f0 100644
--- a/main.py
+++ b/main.py
@@ -26,17 +26,24 @@ def load_cpu(deadline):
while time.time() - start < 0.2*deadline:
math.pow(random.randint(0, 1), random.randint(0, 1))
+def join_process(job, timeout):
+ time_start = time.time()
+ while time.time()-time_start < timeout and job.is_alive():
+ time.sleep(0.1 * timeout)
+ continue
+
job_counter = 0
+lock = threading.Lock()
def spawn_job(deadline):
'''
Creat a new Process, call join(), process errors
'''
global job_counter
time_start = time.time()
- job = multiprocessing.Process(target=load_cpu, args=(deadline, ))
- job.start()
- # timeout=None in the call to join() solves the problem
- job.join(deadline)
+ with lock:
+ job = multiprocessing.Process(target=load_cpu, args=(deadline, ))
+ job.start()
+ join_process(job, deadline) |
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2020-06-10 12:13:49 | Arkady M | set | recipients: + Arkady M, pitrou, davin |
| 2020-06-10 12:13:49 | Arkady M | set | messageid: <1591791229.94.0.657635762104.issue40860@roundup.psfhosted.org> |
| 2020-06-10 12:13:49 | Arkady M | link | issue40860 messages |
| 2020-06-10 12:13:49 | Arkady M | create |
Powered by Roundup Copyright © 1990-2022, Python Software Foundation
Legal Statements
