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) { return(APIResultCode(TempPyMOLGlobals->Ready)); } should be static PyObject *CmdReady(PyObject *dummy, PyObject *args) { if(TempPyMOLGlobals) { return(APIResultCode(TempPyMOLGlobals->Ready)); } else { return(APIResultCode(0)); } } since TempPyMOLGlobals can't be derefrenced until it exists. 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=threading.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. Principal Scientist . DeLano Scientific LLC . 400 Oyster Point Blvd., Suite 213 . South San Francisco, CA 94080 USA . Biz:(650)-872-0942 Tech:(650)-872-0834 . Fax:(650)-872-0273 Cell:(650)-346-1154 . mailto:war...@delsci.com > -----Original Message----- > From: Dmitriy Igor Bryndin [mailto:brynd...@msu.edu] > Sent: Tuesday, October 11, 2005 5:06 AM > To: Warren DeLano > Cc: pymol-users@lists.sourceforge.net > Subject: Re: [PyMOL] PyMol segmentation fault while starting > from external python program > > Warren > > It seems like PyMol should have time to load after import > pymol and before anything else can be done with it. > If I´ll do > ------------------------------ > pymol_argv = ['pymol', '-qx'] > import pymol > # let`s give pymol some time to load > for a in range(1000000): > b=0 > > pymol.finish_launching() > > from pymol import cmd > > cmd.load("$HOME/pept.pdb") > cmd.show("sticks") > ------------------------------ > everything is fine. It loads and shows the picture. > ´for a in range(100)´ for example will produce segmentation fault. > > As far as I understand ´pymol.finish_launching()´ is meant to > produce such delay. Correct me if I´m wrong. But this call > produce segm fault by itself without a waiting cycle. > > Can you recommend some workaround for this problem? This > stupid cycle may work on my machine, but may not work on a > faster one. Is there any way to find out that PyMol window > had loaded? > > Thanks > Dmitriy Bryndin > > > > > > > > > Warren DeLano writes: > > > Dmitriy, > > > > Due to problem with multithreading (especially with the Tcl/Tk > > external GUI), we haven't been able to get the "import > pymol" approach to work in > > a stable robust manner across different OSes and environments. > > > > So sight now, as per comments in > "modules/pymol/__init__.py", the only > > supported way to launch PyMOL is to run the __init__.py script on > > startup. > > > > %python modules/pymol/__init__.py > > > > Hoever, if you disable the external GUI, then you might be > able to get > > "import pymol" to work... > > > > pymol_argv = ['pymol', '-qx'] > > import pymol > > pymol.finish_launching() > > > > from pymol import cmd > > > > cmd.load(...etc. > > > > > > Cheers, > > Warren > > > > > > -- > > Warren L. DeLano, Ph.D. > > Principal Scientist > > > > . DeLano Scientific LLC > > . 400 Oyster Point Blvd., Suite 213 > > . South San Francisco, CA 94080 USA > > . Biz:(650)-872-0942 Tech:(650)-872-0834 > > . Fax:(650)-872-0273 Cell:(650)-346-1154 > > . mailto:war...@delsci.com > > > > > >> -----Original Message----- > >> From: pymol-users-ad...@lists.sourceforge.net > >> [mailto:pymol-users-ad...@lists.sourceforge.net] On Behalf > Of Dmitriy > >> Igor Bryndin > >> Sent: Monday, October 10, 2005 2:33 PM > >> To: pymol-users@lists.sourceforge.net > >> Subject: [PyMOL] PyMol segmentation fault while starting from > >> external python program > >> > >> Launching PyMol form external python script will produce > >> 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. > >> > >> Tried it on Fedora Core 1, Fedora Core 4, Mandriva 2005. The same > >> story. > >> Different pythons and compiling different versions of > PyMol does not > >> change anything. > >> > >> It will launch PyMol windows if there is only > >> import pymol > >> line. > >> > >> 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. > >> > >> The same time if I'll try to debug step by step, let's say, > >> "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, > >> changes to sticks... > >> Running it "python launch_demo.py" will wait for a second > and return > >> segmentation fault. > >> > >> If someone knows what's going on, please help me. > >> > >> Thanks > >> Dmitriy Bryndin > >> > >> > >> > >> > >> > >> ------------------------------------------------------- > >> This SF.Net email is sponsored by: > >> Power Architecture Resource Center: Free content, downloads, > >> discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl > >> _______________________________________________ > >> PyMOL-users mailing list > >> PyMOL-users@lists.sourceforge.net > >> https://lists.sourceforge.net/lists/listinfo/pymol-users > >> > >> > >> > >> > > > > > > > > >