diff options
author | VG <vg@devys.org> | 2016-04-21 23:21:13 +0200 |
---|---|---|
committer | VG <vg@devys.org> | 2016-04-21 23:21:13 +0200 |
commit | b4dc0e4e38e5ad1c02915b1b1dd44e0e5d7816ce (patch) | |
tree | 1269e7c9fcb053807c37e9c6317f5cc2f904bbc6 /test.py | |
parent | 3947ef7790eba735b6d56a6f0a88b1dff39e89dd (diff) | |
parent | 159bca83e8f9d717a5b754ae22ed7a69983c0225 (diff) | |
download | teaqueue-b4dc0e4e38e5ad1c02915b1b1dd44e0e5d7816ce.tar.gz teaqueue-b4dc0e4e38e5ad1c02915b1b1dd44e0e5d7816ce.tar.bz2 teaqueue-b4dc0e4e38e5ad1c02915b1b1dd44e0e5d7816ce.zip |
Merge conflict autocommit on 807fe7afb37fe2cfcf15c9457d04f64fa11b7511
Diffstat (limited to 'test.py')
-rw-r--r-- | test.py | 36 |
1 files changed, 36 insertions, 0 deletions
@@ -0,0 +1,36 @@ +#!/usr/bin/env python3 + + +import contextlib +import os +import random +import socket +import subprocess + + +procs = [] +procmax = 2 +s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) +with contextlib.suppress(FileNotFoundError): + os.unlink('socket') +s.bind(b'socket') +s.listen(0) +while True: + client, _ = s.accept() + line = client.recv(1024) + if not line.endswith(b'\n'): + client.close() + continue + filename = line.rstrip() + client.close() + + print('running for filename {}'.format(filename)) + + p = subprocess.Popen("sleep {} && echo ffmpeg {}" + .format(random.randint(1, 10), filename), shell=True) + + procs.append(p) + + if len(procs) >= procmax: + os.wait() + procs = list(p for p in procs if p.poll() is not None) |