On Jun 13, 10:25 am, Mike Kazantsev <mk.frag...@gmail.com> wrote: > On Thu, 11 Jun 2009 22:35:15 -0700 > Dennis Lee Bieber <wlfr...@ix.netcom.com> wrote: > > > > > On Thu, 11 Jun 2009 08:44:24 -0500, "Strax-Haber, Matthew (LARC-D320)" > > <matthew.strax-ha...@nasa.gov> declaimed the following in > > gmane.comp.python.general: > > > > I sent this to the Tutor mailing list and did not receive a response. > > > Perhaps one of you might be able to offer some sagely wisdom or pointed > > > remarks? > > > > Please reply off-list and thanks in advance. Code examples are below in > > > plain text. > > > Sorry -- you post to a public forum, expect to get the response on a > > public forum... > > > > > My program runs interactively by allowing the user to directly > > > > interact with the python prompt. This program has a runAll() method > > > > that runs a series of subprocesses with a cap on how many instances > > > > are running at a time. My intent is to allow the user to use Ctrl-C to > > > > break these subprocesses. Note that while not reflected in the demo > > > Are they subprocesses or threads? Your sample code seems to be using > > threads. > > > When using threads, there is no assurance that any thread other than > > the main program will receive a keyboard interrupt. > > In fact, no thread other than the main will get interrupt. > > > > > > def runAll(): > > > workers = [ Thread(target = runSingle, args = [i]) > > > for i in xrange(MAX_SUBPROCS + 1) ] > > > try: > > > for w in workers: > > > w.start() > > > except KeyboardInterrupt: > > > ## I want this to be shown on a KeyboardInterrupt > > > print '********* stopped midway ********' > > > You are unlikely to see that... After you start the defined worker > > /threads/ (which doesn't take very long -- all threads will be started, > > but some may immediately block on the semaphore) this block will exit > > and you will be at... > > > > for w in workers: > > > w.join() > > > ... a .join() call, which is the most likely position at which the > > keyboard interrupt will be processed, killing the main program thread > > and probably generating some errors as dangling active threads are > > forceably killed. > > There was quite interesting explaination of what happens when you send > ^C with threads, posted on concurrency-sig list recently: > > http://blip.tv/file/2232410 > http://www.dabeaz.com/python/GIL.pdf > > Can be quite shocking, but my experience w/ threads only confirms that. > > -- > Mike Kazantsev // fraggod.net > > signature.asc > < 1KViewDownload
Thank you very much for the link Mike. Are there other videos/audio like this? I am learning more from these videos than by experience alone. I did find one - http://www.awaretek.com/python/ - are there other links? -- http://mail.python.org/mailman/listinfo/python-list