0

Bit of a python noob, but I was wondering …

I want to start a thread on start up and pass udp socket data to the thread when it comes in for the thread to process AND then respond to the client accordingly.

All the examples I have seen so far create a thread, do something, bin it, repeat. I don’t want thousands of threads to be created, just one to handle message data of a particular type.

Is this possible and does anyone know of any examples ? Thanks

1 Answers1

0

Yes, it is possible. Do note however that you will not gain throughput this way unless you are able to process the datagrams using a compiled extension module like NumPy or some custom logic.

John Zwinck
  • 239,568
  • 38
  • 324
  • 436
  • thanks, i can get into the the thread to process the data but can't seem to send any data back to the client from within the worker thread –  May 17 '17 at 14:02
  • 1
    That sort of depends on what it means to process. If your processing involves operations that can block (non-async database access, other network traffic, etc) you may well benefit from threads. – Sam Hartman May 17 '17 at 14:04
  • Can anyone provide an example on how this may be done? I've been playing around with queue. QUEUE to no avail. Thanks –  May 17 '17 at 14:55