synchronize a block

T

Thomas Rademacher

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?

Thank's for your hints, Thomas
 
P

Peter Hansen

Thomas said:
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).

-Peter
 
S

Steve Holden

Peter said:
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
 
P

Peter Hansen

Steve said:
"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.

Sometimes, and more so lately, *painfully* slowly. I'm somewhat
saddened by the waste involved in some of those threads where the
OP posts a vague question, we all spend days replying with various
guesses at what was really intended, and then finally the OP
posts again (and sometimes they don't even do us that courtesy!)
and says merely "oh, it wasn't that complicated, I just meant X"
and it turns out to have been a FAQ item anyway. :-(

But then, Steve, you're an optimist and I'm not. ;-)

-Peter
 
R

Richard Hanson

Peter said:
Sometimes, and more so lately, *painfully* slowly. I'm somewhat
saddened by the waste involved in some of those threads where the
OP posts a vague question, we all spend days replying with various
guesses at what was really intended, and then finally the OP
posts again (and sometimes they don't even do us that courtesy!)
and says merely "oh, it wasn't that complicated, I just meant X"
and it turns out to have been a FAQ item anyway. :-(

While I'm in complete agreement with your sentiments above, Peter,
newsgroup dynamics *are* difficult. Speaking for myself, both you and
Steve (and virtually all other respondents) have been *quite* helpful
and friendly to me. But attempting to follow the customs of a group
can be a bit intimidating for some newer posters. While I'm not
intimidated (alas, eh? ;-) ), I've been told by different long-term
posters -- all with the best of intentions, I firmly believe -- that
I've given too *much* information in some cases, as well as too
*little* information in other cases. (And usually, they were correct.
;-) ) I'm fully capable of adjusting up and learning as needed -- and
I most *certainly* don't take any of this personally, in any case.
However, many of the newbies may not fare so well.

Mostly, in this group, people are quite civil and mature -- even in
the face of repeated problems such as you mention above. But that is
not the case universally -- here, or in any other group. Indeed, in
the world at large.

I have no answers, as it were. Likely, we're all going to have to hold
on tight as we careen into this 'Fraid New World, stumbling along,
working things out as we go. :)
But then, Steve, you're an optimist and I'm not. ;-)

;-)


cautiously-pessimistically y'rs,
Richard Hanson
 
P

Peter Maas

Peter said:
Sometimes, and more so lately, *painfully* slowly. I'm somewhat
saddened by the waste involved in some of those threads where the
OP posts a vague question, we all spend days replying with various
guesses at what was really intended, and then finally the OP
posts again (and sometimes they don't even do us that courtesy!)
and says merely "oh, it wasn't that complicated, I just meant X"
and it turns out to have been a FAQ item anyway. :-(

The best way to minimize c.l.py effort is to behave like an expert
system:

synchronize: unknown. Please explain.
 
P

Peter Hansen

Peter said:
The best way to minimize c.l.py effort is to behave like an expert
system:

synchronize: unknown. Please explain.

Maybe, but then I get emails telling me I'm being rude. :-(
 
S

Steve Holden

Peter said:
Maybe, but then I get emails telling me I'm being rude. :-(

Well Thomas, who asked the original question, has been so dumbstruck by
this outpouring of irrelevant response that he has thereafter failed to
enlighten us about what he really wants. So I guess we are talking to
ourselves here :)

regards
Steve
 
J

Jorge Godoy

Peter Hansen said:
Maybe, but then I get emails telling me I'm being rude. :-(

If we send you emails telling you you're nice would you do that? :)
Maybe making a weekly "admin" post with guidelines and directions on
where to look first is a good thing. All the people that are not
interested on that can filter it out...


Be seeing you,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,208
Messages
2,571,082
Members
47,683
Latest member
AustinFairchild

Latest Threads

Top