Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #73026
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <carlos@premium-sponsor.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.008 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'cache': 0.07; 'failing': 0.07; 'lines,': 0.07; 'don': 0.09; 'exit': 0.09; 'skip:$ 20': 0.09; 'skip:$ 30': 0.09; 'skip:$ 40': 0.09; 'received:localdomain': 0.11; 'python': 0.11; 'def': 0.12; 'thread': 0.14; 'skip:$ 50': 0.16; 'skip:/ 60': 0.16; 'skip:f 80': 0.16; 'skip:u 50': 0.16; 'such,': 0.16; 'thread?': 0.16; 'true:': 0.16; 'attach': 0.16; 'skip:= 10': 0.16; 'filename:fname piece:txt': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'example': 0.22; 'import': 0.22; 'shell': 0.22; 'header:User-Agent:1': 0.23; 'certainly': 0.24; 'skip:i 40': 0.24; 'text,': 0.24; 'script': 0.25; 'skip:" 30': 0.26; 'skip:" 20': 0.27; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'see,': 0.30; 'skip:( 20': 0.30; 'code': 0.31; 'lines': 0.31; 'break;': 0.31; 'embed': 0.31; 'os,': 0.31; 'prints': 0.31; 'skip:= 20': 0.31; 'another': 0.32; 'skip:# 10': 0.33; 'skip:t 40': 0.33; "i'd": 0.34; 'skip:u 20': 0.35; 'anybody': 0.35; 'but': 0.35; 'add': 0.35; 'skip:> 10': 0.36; 'skip:f 40': 0.36; 'next': 0.36; 'hi,': 0.36; 'two': 0.37; 'received:76': 0.38; 'whatever': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'skip:u 10': 0.60; 'skip:i 50': 0.60; 'new': 0.61; "you're": 0.61; 'first': 0.61; 'show': 0.63; 'soon': 0.63; 'provide': 0.64; 'more': 0.64; 'skip:f 50': 0.65; 'due': 0.66; 'header:Reply-To:1': 0.67; 'prompt': 0.68; 'reply-to:no real name:2**0': 0.71; 'url:v': 0.71; 'url:youtube': 0.71; 'url:watch': 0.77; 'skip:$ 10': 0.81; 'gelonida': 0.84; 'carlos': 0.91 |
| Date | Mon, 09 Jun 2014 14:34:56 +0100 |
| From | Carlos Anselmo Dias <carlos@premium-sponsor.com> |
| User-Agent | Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: embedding ipython kernel in a thread |
| References | <ln4b4b$bda$1@ger.gmane.org> |
| In-Reply-To | <ln4b4b$bda$1@ger.gmane.org> |
| Content-Type | multipart/mixed; boundary="------------040004000502090606040904" |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| Reply-To | carlos@premium-sponsor.com |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.10911.1402320905.18130.python-list@python.org> (permalink) |
| Lines | 188 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1402320905 news.xs4all.nl 2831 [2001:888:2000:d::a6]:43509 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:73026 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
On 06/09/2014 01:59 PM, Gelonida N wrote:
> Hi,
>
> I'd like to embed an ipython kernel in an appliction, such, that I can
> use
>
> ipython console --existing kernel-<pid>.json lateron to connect to it
> and to look at some values
>
>
> Due to various reason I don not want to start it in the main thread.
>
> If you look at following example you will see, that I can start an
> ipython kernel and
> connect to it as long as I start it in the main thread.
>
> as soon as I start the kernel in another thread my ipython client
> prints the first few lines and a welcome text, but
> no prompt is shown.
>
> Does anybody know a way o how to start IPython outside of the main
> thread?
>
>
> Below code trying to show a working setup with ipython kernel in the
> main thread and failing if ipython kernel is started from another thread
>
> #!/usr/bin/env python
> import os, time, threading
> from IPython import embed_kernel
>
> cnt = { 'value' : 0 }
> def run_ip_kernel():
> embed_kernel(local_ns={ 'cnt': cnt})
>
> def example_thread():
> while True:
> cnt['value'] += 1
> print(cnt['value'])
> time.sleep(5)
>
> main_thread = run_ip_kernel
> other_thread = example_thread
>
> # if I uncomment the next two lines, then I can no more
> # execute my interactive IPython shell
> #main_thread = example_thread
> #other_thread = run_ip_kernel
>
> print("now you can try to connect to this shell with:")
> print("ipython console --existing kernel-%d.json" % os.getpid())
> threading.Thread(target=other_thread).start()
> main_thread()
>
>
Whatever you're trying to do(...) ... if you look at the script I
provide you in attach and if you can think how usefull it would be to
control exponencially what you need ... that's certainly one best
approach ...
https://www.youtube.com/watch?v=p7CaiWxKYBo
Regards,
Carlos
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: embedding ipython kernel in a thread Carlos Anselmo Dias <carlos@premium-sponsor.com> - 2014-06-09 14:34 +0100
csiph-web