[Biopython] help with ncbiWWW

Peter Cock p.j.a.cock at googlemail.com
Wed Jul 26 15:18:48 UTC 2017


On Wed, Jul 26, 2017 at 1:37 PM, Nabeel Ahmed
<chaudhrynabeelahmed at gmail.com> wrote:
> Hi,
>
> Disclaimer: I haven't used ncbiWWW module.
>
> Suggestion 1: if you're using a *NIX system. Can make use of Signals. Wrap
> your call with the signal. Define the signal handler:

I think that approach would work here - thanks!

> Suggestion 2: using Multiprocessing or multithreading - for it, kindly share
> your script/snippet.

Again that would likely work, but will be more complicated.

> Suggestion 3: Make direct API calls using 'requests' package.
> In case the API calls are simple (you can easily do so) use request to make
> a call, with timeout flag, once the HTTP request will timeout it'll raise
> Timeout exception, which you can catch and in that block make the second
> call (which as per you, works perfectly fine):

This is essentially the idea I was initially suggesting, but the problem
isn't actually in the online request (currently done by urlopen).

With the NCBI BLAST you typically submit a query, wait, check for
progress, wait (repeat), and then download the results. This loop in
Biopython has no timeout - it relies on the NCBI returning results
eventually - or giving an error.

Peter


More information about the Biopython mailing list