synchronize a block

Peter Hansen peter at
Mon Sep 27 14:10:24 CEST 2004

Thomas Rademacher wrote:
> Hallo,
> I want to synchronize the main function of my script. I havn't a class
> structure in my script.
> def main():
>     # my code to synchronized
> if __name__=='__main__':
>     main()
> How can I resolve this problem simply?

What do you mean here by "synchronize"?  Normally, I believe,
it's a term used in multithreaded applications...  it has
nothing to do with "class structures" or anything else other
than as a means to coordinate two or more threads of execution.

(Guessing) If you have seen examples of code that does
synchronize but it's all based on subclasses of threading.Thread,
then maybe you just need to know that the main thread is
actually wrapped with a proxy in the threading class when
it's imported, and you can just use any normal synchronization
technique that you would have used in a thread subclass...
(somehow I doubt that's where you were going with this).


More information about the Python-list mailing list