vanatteveldt / nlpipe

Client/server based NLP Pipelining
MIT License
1 stars 2 forks source link

Push notification of new task #9

Closed vanatteveldt closed 7 years ago

vanatteveldt commented 8 years ago

The original design is a pull system, i.e. workers pull the server periodically to ask if there is something to do. If we want, we could add a list of worker pids per task or per server, and use these to wake up the workers on adding a new document to the queue. Below is some test code that shows how this could be done:

import signal
import time
import os

class SleepInterrupted(Exception):
    pass

def handler(signum, frame):
    raise SleepInterrupted()

signal.signal(signal.SIGCONT, handler)

pid = os.getpid()
while True:
    print("Sleeping, feel free to wake me up with 'kill -s SIGCONT {pid}' ..."
          .format(**locals()))
    try:
        time.sleep(10)
    except SleepInterrupted:
        pass
    print("Polling queue")
vanatteveldt commented 7 years ago

I'll just wontfix myself here :)