synchronize a block

Steve Holden steve at holdenweb.com
Mon Sep 27 08:38:22 EDT 2004


Peter Hansen wrote:

> 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).
> 
"In the face of ambiguity, refuse the temptation to guess" :-)

One of the best features of c.l.py is how questions phrased in the most 
ambiguous terms are often slowly elaborated into meaningful enquiries.

regards
  Steve



More information about the Python-list mailing list