picture_server.py 483 B

1234567891011121314151617181920212223242526
  1. # coding:utf-8
  2. from a2s.a2s_server import watch
  3. import multiprocessing
  4. import random
  5. import time
  6. @watch
  7. def run(data: bytes, *args, **kwargs):
  8. t=random.randint(4,30)
  9. time.sleep(t)
  10. return data
  11. def worker():
  12. run(nats_host="192.168.3.240", nats_port=19090, subject="test2img", queue="main")
  13. def add_picture_process():
  14. new_process = multiprocessing.Process(target=worker)
  15. new_process.start()
  16. return new_process
  17. if __name__ == '__main__':
  18. worker()