From: Warren D. <wa...@de...> - 2005-10-11 14:23:43
|
Dmitriy, I spent a few minutes yesterday trying to track down the seg. fault -- = there are at least three issues here... One appears to be a race condition inside of Tcl/Tk-to-Python call = interface, which is most apparent on multi-cpu systems, and for which I = have no solution yet other than disabling the external GUI altogether. The second is a blunder on my part in the CmdReady function in = layer4/Cmd.c: static PyObject *CmdReady(PyObject *dummy, PyObject *args)=20 { return(APIResultCode(TempPyMOLGlobals->Ready)); } should be static PyObject *CmdReady(PyObject *dummy, PyObject *args)=20 { if(TempPyMOLGlobals) { return(APIResultCode(TempPyMOLGlobals->Ready)); } else { return(APIResultCode(0)); } } since TempPyMOLGlobals can't be derefrenced until it exists. =20 The third issue appears to be a Python initialization issue that also = only rears its ugly head on SMP machines: finish_launching() in modules/pymol/__init__.py needs to be updated as = follows: def finish_launching(): e=3Dthreading.Event() while not hasattr(__main__,'pymol'): e.wait(0.01) while not _cmd.ready(): e.wait(0.01) while not hasattr(__main__.pymol,'xray'): e.wait(0.01) in order to allow time for the xray module to initialize before loading = structures. These changes have been committed to CVS. Cheers, Warren -- Warren L. DeLano, Ph.D. =20 Principal Scientist . DeLano Scientific LLC =20 . 400 Oyster Point Blvd., Suite 213 =20 . South San Francisco, CA 94080 USA =20 . Biz:(650)-872-0942 Tech:(650)-872-0834 =20 . Fax:(650)-872-0273 Cell:(650)-346-1154 . mailto:wa...@de... =20 =20 > -----Original Message----- > From: Dmitriy Igor Bryndin [mailto:bry...@ms...]=20 > Sent: Tuesday, October 11, 2005 5:06 AM > To: Warren DeLano > Cc: pym...@li... > Subject: Re: [PyMOL] PyMol segmentation fault while starting=20 > from external python program >=20 > Warren=20 >=20 > It seems like PyMol should have time to load after import=20 > pymol and before anything else can be done with it. > If I=B4ll do > ------------------------------ > pymol_argv =3D ['pymol', '-qx'] > import pymol > # let`s give pymol some time to load > for a in range(1000000): > b=3D0=20 >=20 > pymol.finish_launching()=20 >=20 > from pymol import cmd=20 >=20 > cmd.load("$HOME/pept.pdb") > cmd.show("sticks") > ------------------------------ > everything is fine. It loads and shows the picture. > =B4for a in range(100)=B4 for example will produce segmentation = fault.=20 >=20 > As far as I understand =B4pymol.finish_launching()=B4 is meant to=20 > produce such delay. Correct me if I=B4m wrong. But this call=20 > produce segm fault by itself without a waiting cycle.=20 >=20 > Can you recommend some workaround for this problem? This=20 > stupid cycle may work on my machine, but may not work on a=20 > faster one. Is there any way to find out that PyMol window=20 > had loaded?=20 >=20 > Thanks > Dmitriy Bryndin=20 >=20 > =20 >=20 > =20 >=20 > =20 >=20 >=20 > Warren DeLano writes:=20 >=20 > > Dmitriy, > >=20 > > Due to problem with multithreading (especially with the Tcl/Tk=20 > > external GUI), we haven't been able to get the "import=20 > pymol" approach to work in > > a stable robust manner across different OSes and environments. =20 > >=20 > > So sight now, as per comments in=20 > "modules/pymol/__init__.py", the only=20 > > supported way to launch PyMOL is to run the __init__.py script on=20 > > startup. > >=20 > > %python modules/pymol/__init__.py > >=20 > > Hoever, if you disable the external GUI, then you might be=20 > able to get=20 > > "import pymol" to work... > >=20 > > pymol_argv =3D ['pymol', '-qx'] > > import pymol > > pymol.finish_launching() > >=20 > > from pymol import cmd > >=20 > > cmd.load(...etc.=20 > >=20 > >=20 > > Cheers, > > Warren > >=20 > >=20 > > -- > > Warren L. DeLano, Ph.D. =20 > > Principal Scientist > >=20 > > . DeLano Scientific LLC =20 > > . 400 Oyster Point Blvd., Suite 213 =20 > > . South San Francisco, CA 94080 USA =20 > > . Biz:(650)-872-0942 Tech:(650)-872-0834 =20 > > . Fax:(650)-872-0273 Cell:(650)-346-1154 > > . mailto:wa...@de... =20 > > =20 > >=20 > >> -----Original Message----- > >> From: pym...@li... > >> [mailto:pym...@li...] On Behalf=20 > Of Dmitriy=20 > >> Igor Bryndin > >> Sent: Monday, October 10, 2005 2:33 PM > >> To: pym...@li... > >> Subject: [PyMOL] PyMol segmentation fault while starting from=20 > >> external python program > >>=20 > >> Launching PyMol form external python script will produce=20 > >> segmaentation fault. > >> For example starting "launch.py" from "/pymol/examples/launching" > >> ---------------------------------------------- > >> $ python launch.py > >> zsh: segmentation fault python launch.py > >> ---------------------------------------------- > >> Crashes without even showing PyMol windows. =20 > >>=20 > >> Tried it on Fedora Core 1, Fedora Core 4, Mandriva 2005. The same=20 > >> story. > >> Different pythons and compiling different versions of=20 > PyMol does not=20 > >> change anything. > >>=20 > >> It will launch PyMol windows if there is only > >> import pymol > >> line. =20 > >>=20 > >> Adding > >> pymol.finish_launching() > >> or > >> from pymol import cmd > >> cmd.load("$PYMOL_PATH/test/dat/pept.pdb") > >> will produce segmentation fault. With no windows shown. =20 > >>=20 > >> The same time if I'll try to debug step by step, let's say,=20 > >> "launch_demo.py" > >> (from "/pymol/examples/launching") > >> ------------------------------- > >> pymol.finish_launching() > >> from pymol import cmd > >> cmd.load("$PYMOL_PATH/test/dat/pept.pdb") > >> cmd.show("sticks") > >> ------------------------------- > >> using IDLE. Everything will work. It starts windows, loads a file,=20 > >> changes to sticks... > >> Running it "python launch_demo.py" will wait for a second=20 > and return=20 > >> segmentation fault. > >>=20 > >> If someone knows what's going on, please help me. =20 > >>=20 > >> Thanks > >> Dmitriy Bryndin > >>=20 > >> =20 > >>=20 > >> =20 > >>=20 > >> ------------------------------------------------------- > >> This SF.Net email is sponsored by: > >> Power Architecture Resource Center: Free content, downloads,=20 > >> discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl > >> _______________________________________________ > >> PyMOL-users mailing list > >> PyM...@li... > >> https://lists.sourceforge.net/lists/listinfo/pymol-users > >>=20 > >> =20 > >>=20 > >>=20 > >=20 > =20 >=20 >=20 >=20 >=20 >=20 >=20 |