logo       

Re: [BioPython] Is BioPython thread safe?: msg#00031

python.bio.general

Subject: Re: [BioPython] Is BioPython thread safe?

Hi Mike,
Thanks for the response... I really appreciate it. I'll look into the semaphor solution or just make an external command line program which I can call from another python program. Thanks again!

-Brandon King

Mike Cariaso wrote:

I only use biopython occasionally, but have been
through similar issues with perl, and will share what
I can.

I think the lack of responses indicates that no one
can say authoritatively, since there are so many
developers. Presumably some parts of biopython are threadsafe, but that may be more a matter of luck than
of design.
Doing threadsafe signals is considerably more complex
than non-threadsafe. If you don't see a lot of code
gymnastics and comments about threads, any library
using signals for is very unlikely to be threadsafe.

if you need biopython and threads, you'll probably
have to wrap all biopython code behind a single
semaphore, and prevent concurrent access. Depending on
what you're doing this may serialize all your code, or
only a portion. Manually inspect the most crucial
biopython components and see if you can use multiple
semaphors, perhaps one for pieces which use signals,
and another for components which read/write class
variables. Gradually keep decreasing the granularity
of the semaphors. Also look for places where signals
are used only as timeouts, and replace these with
another thread.

Its probably going to be real painful.



--- Brandon King <kingb@xxxxxxxxxxx> wrote:


Hello All,
Did I not give enough information about the
problem? Any one have any suggestions or ideas?

-Brandon King

Brandon King wrote:


Hi All,
I'm trying to use BioPython within a thread of

my main program and
I end up getting this error. Is BioPython intended

to be thread safe?

TraceBack:
<snip>
from Bio.Blast import NCBIStandalone
File

"/usr/lib/python2.3/site-packages/Bio/__init__.py",
line 106, in ?

_load_registries()
File

"/usr/lib/python2.3/site-packages/Bio/__init__.py",
line 98, in
_load_registries
module = __import__("Bio.config.%s" % module,

{}, {},
["Bio","config"])
File

"/usr/lib/python2.3/site-packages/Bio/config/FormatRegistry.py",

line 26, in ?
import _support
File

"/usr/lib/python2.3/site-packages/Bio/config/_support.py",

line
26, in ?
from Bio.MultiProc.copen import copen_fn
File

"/usr/lib/python2.3/site-packages/Bio/MultiProc/copen.py",

line
322, in ? signal.signal(signal.SIGTERM,

_handle_sigterm)

ValueError: signal only works in main thread

-Brandon King

_______________________________________________
BioPython mailing list - BioPython@xxxxxxxxxxxxx
http://biopython.org/mailman/listinfo/biopython



_______________________________________________
BioPython mailing list - BioPython@xxxxxxxxxxxxx
http://biopython.org/mailman/listinfo/biopython




=====
Mike Cariaso




_______________________________________________
BioPython mailing list - BioPython@xxxxxxxxxxxxx
http://biopython.org/mailman/listinfo/biopython



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise