Skip to content
Snippets Groups Projects
Commit 175533c8 authored by Nathaniel Manista's avatar Nathaniel Manista
Browse files

Merge pull request #758 from ctiller/test

Use signals instead of sleep to wait for jobs
parents a512c33e 336ad509
No related branches found
No related tags found
No related merge requests found
...@@ -33,6 +33,7 @@ import hashlib ...@@ -33,6 +33,7 @@ import hashlib
import multiprocessing import multiprocessing
import os import os
import random import random
import signal
import subprocess import subprocess
import sys import sys
import tempfile import tempfile
...@@ -42,6 +43,12 @@ import time ...@@ -42,6 +43,12 @@ import time
_DEFAULT_MAX_JOBS = 16 * multiprocessing.cpu_count() _DEFAULT_MAX_JOBS = 16 * multiprocessing.cpu_count()
# setup a signal handler so that signal.pause registers 'something'
# when a child finishes
# not using futures and threading to avoid a dependency on subprocess32
signal.signal(signal.SIGCHLD, lambda unused_signum, unused_frame: None)
def shuffle_iteratable(it): def shuffle_iteratable(it):
"""Return an iterable that randomly walks it""" """Return an iterable that randomly walks it"""
# take a random sampling from the passed in iterable # take a random sampling from the passed in iterable
...@@ -232,7 +239,7 @@ class Jobset(object): ...@@ -232,7 +239,7 @@ class Jobset(object):
if dead: return if dead: return
message('WAITING', '%d jobs running, %d complete, %d failed' % ( message('WAITING', '%d jobs running, %d complete, %d failed' % (
len(self._running), self._completed, self._failures)) len(self._running), self._completed, self._failures))
time.sleep(0.1) signal.pause()
def cancelled(self): def cancelled(self):
"""Poll for cancellation.""" """Poll for cancellation."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment