[Twisted-Python] Concurrent data access with select() safe?

Mukhsein Johari arashi1 at pd.jaring.my
Tue Aug 13 15:37:09 EDT 2002


On Wednesday 14 August 2002 02:28, Matt Campbell wrote:
> On Wed, Aug 14, 2002 at 02:09:19AM +0800, Mukhsein Johari wrote:
> > I've managed to get a working custom webserver thanks to Donovan. My next
> > question is (perhaps more due to my ignorance of how select works) how do
> > you control concurrent access to data?
>
> There is no concurrent access to data in a single-threaded,
> event-based system, because the event handlers which are run by
> the main loop are never interrupted.  A function always runs to
> completion, as if it's always running in a critical section. (This
> is also why no blocking system calls should be performed except in
> the main loop itself.)

Sorry for being so dense but, what do you mean by this? Does file access count 
as blocking (my gut says "yes")? How would you handle that? In the twisted 
system in general, from what I understand of it, classes are instantiated to 
handle client requests. If those instances access files or in-memory data 
objects it is conceivable that two instances might be accessing the same data 
/ file, right? But from you you say, this is fine since there is only one 
thread. But what do you mean by blocking calls should only be run in the main 
loop? Is the above (file access) blocking? And is it, as the case stated 
above "within the main loop"?


-- 
Regards,
Mukhsein Johari




More information about the Twisted-Python mailing list