Re: embedding ipython kernel in a thread
On 06/09/2014 04:07 PM, Carlos Anselmo Dias wrote: On 06/09/2014 03:55 PM, Gelonida N wrote: Not sure what you are trying to tell me with attached PHP code. Hi ... Nothing important I'd write for what you're seeking ... I'm not one Python expert ... just reading fast what you wrote ... it's certainly one interesting issue if you can control that looking at n machines (...) ... depending on the scope and 'return back' to execute what should be executed I'd write ... Instead of looking to one single machine look at n machines(...) Regards, Carlos Let me add this to finish ... If you think about your example and you consider that it could be used for example in one sort of cache management with remote subtlety ... or whatever ... If the system was hashed(...) ... and you need to delete dependencies(...) ... if the dependencies were in different machines considering that one dependency can be as simple as one serialized/compressed file with information ... Than without thinking too much what you're doing could be used to do something like that ... and exponentially ... you'd control n machines ... and all the dependencies ... I don't know if you understand me ... english is not my maternal language ... I'm not adding more comments to this issue ... Best regards, Carlos -- https://mail.python.org/mailman/listinfo/python-list
Re: embedding ipython kernel in a thread
On 06/09/2014 03:55 PM, Gelonida N wrote: Not sure what you are trying to tell me with attached PHP code. Hi ... Nothing important I'd write for what you're seeking ... I'm not one Python expert ... just reading fast what you wrote ... it's certainly one interesting issue if you can control that looking at n machines (...) ... depending on the scope and 'return back' to execute what should be executed I'd write ... Instead of looking to one single machine look at n machines(...) Regards, Carlos -- https://mail.python.org/mailman/listinfo/python-list
Re: embedding ipython kernel in a thread
On 6/9/2014 3:34 PM, Carlos Anselmo Dias wrote: 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-.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 ... Not sure what you are trying to tell me with attached PHP code. I hope my script is understandable to those who embedded IPython into their own python application. Some details, that I forgot to mention: I'm using IPython 2.0 (the API is different to the predecessor versions) and I based my code on the examples shown on the IPython web site. However the example code doesn't seem to work in any other thread than the main thread. Related link: http://ipython.org/ipython-doc/2/interactive/reference.html#embedding thanks again for any help. I'm rather curious to learn why the embedded kernel seems to block and top find a way to circumvent this behavoiur. -- https://mail.python.org/mailman/listinfo/python-list
Re: embedding ipython kernel in a thread
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-.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 $id_flux["idsponsor"]=2; // $flux_treat=array(397,382,769,770); //$flux_treat=array(397,382); $flux_treat=array(521,6876); $textemailmessage=""; include("../../conf.inc.php"); if(is_array($flux_treat)){ foreach($flux_treat as $kfluxtotreat => $vfluxtotreat){ //echo $kfluxtreatsubtype.""; if(!empty($array_language_flux_default[$vfluxtotreat])){ $id_language_default=$array_language_flux_default[$vfluxtotreat]; } $info_page_records=explode("|",$array_number_records_per_page_start_flux[$vfluxtotreat]); if(is_array($id_flux["detail"][$vfluxtotreat])){ foreach($id_flux["detail"][$vfluxtotreat]["Sponsor"]["url"]["information"]["xml"] as $kfluxtreatsubtype=>$vfluxtreatsubtype){ //control if execution is allowed by kfluxtreatsubtype and add exit echo $kfluxtreatsubtype.""; if(check_lock_control_($kfluxtreatsubtype,"start")=="ok"){ $_ids_types_xml_cache_=$_ids_types_xml_[$kfluxtreatsubtype]; $_time_of_cache_flux_subtype=$_ids_types_xml_time_cache_[$kfluxtreatsubtype]; //echo "time of cache ".$_time_of_cache_flux_subtype.""; if($kfluxtreatsubtype =="xml-movies"){ $number_records_or_end_position=$info_page_records[0]; $counterfilter=0; foreach($id_flux["detail"][$vfluxtotreat]["languages"] as $klg => $vlg){ foreach($ids_cats_sponsor[$vfluxtotreat] as $kcat => $vcat){ $cat_convereted_cache=$vcat; $pagenumb=$limitepaginas=$info_page_records[1]; while ($pagenumb<=$limitepaginas){ $replacements=array($id_flux["idsponsorfk"],$id_flux["loginsponsor"],$id_flux["passwordsponsor"],$kcat,"{idcatsonsponsor}",$pagenumb,$vlg,$number_records_or_end_position,"{filter}",$_SERVER['REMOTE_ADDR'],$id_flux["keysponsor"],"{tracker}","{iditemdetail}","{idsubitemdetail}","{subtracker}"); $urlstringtreat =str_replace($patterns, $replacements, $vfluxtreatsubtype); $
embedding ipython kernel in a thread
Hi, I'd like to embed an ipython kernel in an appliction, such, that I can use ipython console --existing kernel-.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() -- https://mail.python.org/mailman/listinfo/python-list