<div dir="ltr"><div dir="auto">I had the issue on Linux, but it was indeed Anaconda. The issue was frequent enough I had to write the try catch loop, so it should be reproducible if you are willing to submit enough requests (unless the NCBI server suddenly decides to cooperate). <div dir="auto"><br></div><div dir="auto">But indeed, it would need to be changed within the biopython library. You are in the correct place. It hung on urlopen. The code went something like this<br></div><div>while try_counter < max_tries:<br> try:<br></div><div> response = urllib2.urlopen(request, timeout=timeout)<br></div><div> except timeoutexception:<br></div><div> increase try_counter<br></div><div> else:<br></div><div> break #success!<br></div><div dir="auto"><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Jul 26, 2017 13:42, "Peter Cock" <<a href="mailto:p.j.a.cock@googlemail.com" target="_blank">p.j.a.cock@googlemail.com</a>> wrote:<br type="attribution"><blockquote class="gmail-m_3039278716398190551quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">That does help, thank you.<br>
<br>
First of all that tells me you are using Windows and your Python is<br>
from Anaconda (probably not important here).<br>
<br>
Now, I had been guessing the code was getting stuck while actually<br>
connecting to the NCBI and waiting an update - which is where that<br>
socket timeout would come into play.<br>
<br>
I see now the problem is when Biopython checks for an update,<br>
waits for a bit, checks for an update, waits for a bit, ... and never<br>
gives up:<br>
<br>
<a href="https://github.com/biopython/biopython/blob/biopython-170/Bio/Blast/NCBIWWW.py#L164" rel="noreferrer" target="_blank">https://github.com/biopython/b<wbr>iopython/blob/biopython-170/Bi<wbr>o/Blast/NCBIWWW.py#L164</a><br>
<br>
The code increases the wait interval to 120s (two minutes), but<br>
currently has no (optional) maximum total waiting time. Adding<br>
this as an option seems sensible (e.g. a maximum total waiting<br>
time of say 5 or 10 mins).<br>
<br>
Also, it would be good to check if the NCBI is returning some<br>
clue or error message which our code does not understand...<br>
<br>
>From your initial description is sounds like you have not found<br>
any single example which fails - so this is going to be hard to<br>
test.<br>
<br>
Peter<br>
<br>
On Wed, Jul 26, 2017 at 3:04 PM, Pejvak Moghimi<br>
<div class="gmail-m_3039278716398190551elided-text"><<a href="mailto:pejvak.moghimi@york.ac.uk" target="_blank">pejvak.moghimi@york.ac.uk</a>> wrote:<br>
> Hi Peter,<br>
><br>
> Here it is:<br>
><br>
> Traceback (most recent call last):<br>
><br>
> File "<ipython-input-107-561cd74d20<wbr>97>", line 1, in <module><br>
> runfile('D:/Dropbox/Pejvak<br>
> Moghimi/DMT_project/blast_for_<wbr>clav_seqs/blastScript(altered)<wbr>.py',<br>
> wdir='D:/Dropbox/Pejvak Moghimi/DMT_project/blast_for_<wbr>clav_seqs')<br>
><br>
> File<br>
> "C:\Users\pezhv\Anaconda3\lib\<wbr>site-packages\spyder\utils\sit<wbr>e\sitecustomize.py",<br>
> line 880, in runfile<br>
> execfile(filename, namespace)<br>
><br>
> File<br>
> "C:\Users\pezhv\Anaconda3\lib\<wbr>site-packages\spyder\utils\sit<wbr>e\sitecustomize.py",<br>
> line 102, in execfile<br>
> exec(compile(f.read(), filename, 'exec'), namespace)<br>
><br>
> File "D:/Dropbox/Pejvak<br>
> Moghimi/DMT_project/blast_for_<wbr>clav_seqs/blastScript(altered)<wbr>.py", line 116,<br>
> in <module><br>
> result_handle = NCBIWWW.qblast("blastp", "nr", sequence,<br>
> hitlist_size=500, entrez_query = orgn_specified)<br>
><br>
> File "C:\Users\pezhv\Anaconda3\lib\<wbr>site-packages\Bio\Blast\NCBIWW<wbr>W.py",<br>
> line 164, in qblast<br>
> time.sleep(wait)<br>
><br>
><br>
> Cheers,<br>
> Pej.<br>
><br>
><br>
> On 26 July 2017 at 14:57, Peter Cock <<a href="mailto:p.j.a.cock@googlemail.com" target="_blank">p.j.a.cock@googlemail.com</a>> wrote:<br>
>><br>
>> Hi Pej.<br>
>><br>
>> Hmm. Maybe setting the timeout is not going to solve your<br>
>> problem. I was hoping that would be a neat solution.<br>
>><br>
>> Can you show us the stack trace when you had to stop a job<br>
>> please?<br>
>><br>
>> I assume you are using control+c to do this, in which case<br>
>> Python ought to stop with the exception KeyboardInterrupt.<br>
>> What I am interested in here is where in the code Python<br>
>> is getting stuck. That would be a good clue.<br>
>><br>
>> Peter<br>
>><br>
>> On Wed, Jul 26, 2017 at 2:47 PM, Pejvak Moghimi<br>
>> <<a href="mailto:pejvak.moghimi@york.ac.uk" target="_blank">pejvak.moghimi@york.ac.uk</a>> wrote:<br>
>> > Hi Peter,<br>
>> ><br>
>> > That solution, so far, does not seem to have worked nor with 10 neither<br>
>> > with<br>
>> > 30 second options.<br>
>> ><br>
>> > Cheers,<br>
>> > Pej.<br>
>> ><br>
>> > On 26 July 2017 at 13:29, Peter Cock <<a href="mailto:p.j.a.cock@googlemail.com" target="_blank">p.j.a.cock@googlemail.com</a>> wrote:<br>
>> >><br>
>> >> I am hoping that putting this near the start of your script will<br>
>> >> apply the default timeout to all your BLAST calls (or other<br>
>> >> network calls, e.g. NCBI Entrez):<br>
>> >><br>
>> >> import socket<br>
>> >> socket.setdefaulttimeout(30) # timeout in seconds<br>
>> >><br>
>> >> Peter<br>
><br>
><br>
</div><div class="gmail-m_3039278716398190551elided-text">______________________________<wbr>_________________<br>
Biopython mailing list - <a href="mailto:Biopython@mailman.open-bio.org" target="_blank">Biopython@mailman.open-bio.org</a><br>
<a href="http://mailman.open-bio.org/mailman/listinfo/biopython" rel="noreferrer" target="_blank">http://mailman.open-bio.org/ma<wbr>ilman/listinfo/biopython</a><br>
</div></blockquote></div><br></div>
</div>