diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2017-02-26 19:58:19 +0100 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2017-02-26 19:58:19 +0100 |
| commit | f7a1832e217251c59598056c2cc4c44c11fecc88 (patch) | |
| tree | df2d0247248c18f5da79ae97b56b387c4bb86d26 | |
| parent | 3575da2783ba62ddf3784ae814c8fec862c0eb1a (diff) | |
| download | shrinker-f7a1832e217251c59598056c2cc4c44c11fecc88.tar.gz shrinker-f7a1832e217251c59598056c2cc4c44c11fecc88.zip | |
support multiple threads per worker
| -rw-r--r-- | api.py | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -129,15 +129,18 @@ class Worker(object): logging.info("nothing to do, idling") await asyncio.sleep(10) + async def start(self, number=1): + """Start jobs in background.""" + for _ in range(number): + asyncio.ensure_future(self.run()) async def startup(): - for _ in range(1): - worker = Worker() - await worker.connect( - source_db, dest_db - ) - await worker.setup() - await worker.run() + worker = Worker() + await worker.connect( + source_db, dest_db + ) + await worker.setup() + await worker.start(10) logging.basicConfig(level=logging.DEBUG) loop = asyncio.get_event_loop() |
