asynchat and threading

Diez B. Roggisch deetsNOSPAM at web.de
Thu Nov 25 06:25:50 EST 2004


> twisted could be of help here, and which one you would suggest.
> I have a few users (say 100) who want to send small bunches of text
> (say 1K in size) to a remote server via TCP; the server should save
> these texts in a small database. The server should be able to catch the
> messages from the different users and "synchronize" them (not sure what
> the right word is): if two messages arrive at the same time they are
> written one after the other to the database. In this way the database has

If you use twisted with the select-based reactor (which is default) this
should be no problem at all. As there is only one process running, there
can't be a possible concurrent database access. Apart from that, you could
always explicitely guard your critical section of code with a
threading-lock - then you're free to use the thread-based reactor.


-- 
Regards,

Diez B. Roggisch



More information about the Python-list mailing list