3

This is for a moderation bot for C&C Renegade, in case anyone wants some background.

I have a class which will act as a parent to a load of subclasses that provide IRC connections, connections to the gamelog (UDP socket), etc, and I want to know if it is possible to split some of these subclasses (notably the two socket connections [IRC, gamelog]) into their own threads using the threading module.

If anyone has any suggestions, even if it's just saying it can't be done, I'd appreciate the input.

Tom

Edit: I have experience with working with threaded applications, so I'm not a complete noob, honest.

Tom
  • 81
  • 2
  • Don't see why not. A threaded subsystem is not unusual. The fun bit is getting the comms into and out of the subclasses right, ie. flexible enough for various linksk and protocols underneath while providing a common interface via. the overridden methods and callbacks. – Martin James Apr 10 '12 at 22:18

2 Answers2

1

It is feasible, take a look at:

multiprocessing

Besides the simple process forking, it also provides memory sharing - which is likely to be needed.

Krzysztof Rosiński
  • 1,488
  • 1
  • 11
  • 24
0

The best option would be to run your app with gevent coroutines. Those are much more light-weight than threads and processes. The library has been created based on green threads execution units. Here you can find a good comparison and benchmark of the execution models of Eventlet (A python library that provides a synchronous interface to do asynchronous I/O operations which uses green threads to achieve cooperative sockets) and node.js.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
jdavid_1385
  • 107
  • 6