Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #51291
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'interpreter': 0.05; 'attribute': 0.07; 'initialize': 0.07; 'suddenly': 0.07; 'tries': 0.07; 'emulate': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'run,': 0.09; 'python': 0.11; 'thread': 0.14; '"in': 0.16; '55,': 0.16; '70,': 0.16; 'concurrency': 0.16; 'concurrency,': 0.16; 'doc:': 0.16; 'from:addr:behnel.de': 0.16; 'from:addr:stefan_ml': 0.16; 'from:name:stefan behnel': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'stuff,': 0.16; 'thread,': 0.16; 'subject:python': 0.16; 'app': 0.19; 'module': 0.19; 'stefan': 0.19; 'not,': 0.20; 'code,': 0.22; 'example': 0.22; 'import': 0.22; 'print': 0.22; 'header:User- Agent:1': 0.23; 'error': 0.23; 'script': 0.25; 'switch': 0.26; 'gets': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply- To:1': 0.27; 'code': 0.31; '"",': 0.31; 'continues': 0.31; 'releasing': 0.31; 'file': 0.32; 'figure': 0.32; 'stuff': 0.32; 'run': 0.32; 'another': 0.32; '(most': 0.33; 'guess': 0.33; 'maybe': 0.34; 'received:84': 0.35; 'test': 0.35; 'but': 0.35; "didn't": 0.36; 'so,': 0.37; 'to:addr:python-list': 0.38; 'recent': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'according': 0.40; 'release': 0.40; 'ensure': 0.60; 'logs': 0.60; 'then,': 0.60; 'new': 0.61; 'further': 0.61; 'first': 0.61; 'back': 0.62; 'show': 0.63; 'provide': 0.64; 'huh?': 0.84; 'received:arcor-ip.net': 0.84; 'received:pools.arcor-ip.net': 0.84; 'execution,': 0.91 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Stefan Behnel <stefan_ml@behnel.de> |
| Subject | Re: embedded python and threading |
| Date | Fri, 26 Jul 2013 11:29:49 +0200 |
| References | <a6710206-8676-48c8-ad66-95139e695503@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | dslb-084-056-045-139.pools.arcor-ip.net |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130623 Thunderbird/17.0.7 |
| In-Reply-To | <a6710206-8676-48c8-ad66-95139e695503@googlegroups.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5138.1374831002.3114.python-list@python.org> (permalink) |
| Lines | 39 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1374831002 news.xs4all.nl 15904 [2001:888:2000:d::a6]:57745 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:51291 |
Show key headers only | View raw
David M. Cotter, 26.07.2013 08:15:
> in my app i initialize python on the main thread, then immediately call PyEval_SaveThread() because i do no further python stuff on the main thread.
>
> then, for each script i want to run, i use boost::threads to create a new thread, then on that thread i "ensure" the GIL, do my stuff, then release it.
>
> so, to test concurrency, on my first background thread, i do an infinite loop that just logs "i'm alive", then calls sleep(0.25)
>
> so that thread continues to run forever (with it's GIL ensured)
>
> according to the doc: "In order to emulate concurrency of execution, the interpreter regularly tries to switch threads"
>
> so i figure i can run another thread that does a single print statement:
>
>> ensure gil
>> print my thing
>> release gil
>
> and this DOES run. however, after releasing it's gil, i guess the interpeter gets back to the first back thread, but then has this error immediately:
>
> 9: Traceback (most recent call last):
> 9: File "<string>", line 70, in ?
> 9: File "<string>", line 55, in main
> 9: AttributeError: 'builtin_function_or_method' object has no attribute 'sleep'
>
> suddenly the sleep module has been unloaded?? huh? i thought the thread state had been preserved?
You didn't show your code, but as a wild guess, maybe you did
from time import time
instead of
import time
somewhere? If not, please provide the exact example code that you are running.
Stefan
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
embedded python and threading "David M. Cotter" <me@davecotter.com> - 2013-07-25 23:15 -0700
Re: embedded python and threading Stefan Behnel <stefan_ml@behnel.de> - 2013-07-26 11:29 +0200
Re: embedded python and threading "David M. Cotter" <me@davecotter.com> - 2013-07-26 08:57 -0700
Re: embedded python and threading David Robinow <drobinow@gmail.com> - 2013-07-26 12:14 -0400
Re: embedded python and threading John Gordon <gordon@panix.com> - 2013-07-26 16:34 +0000
Re: embedded python and threading "David M. Cotter" <me@davecotter.com> - 2013-07-26 10:25 -0700
Re: embedded python and threading "David M. Cotter" <me@davecotter.com> - 2013-07-26 10:28 -0700
Re: embedded python and threading Stefan Behnel <stefan_ml@behnel.de> - 2013-07-26 20:38 +0200
csiph-web