<div dir="ltr">Hi Peter,<div><br></div><div>Thank you. I will give it a go. <br><br>Can I use this on my own script to achieve what I want, or is it strictly useful for altering the qblast script?</div><div><br></div><div>Cheers,</div><div>Pej.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 26 July 2017 at 13:06, Peter Cock <span dir="ltr"><<a href="mailto:p.j.a.cock@googlemail.com" target="_blank">p.j.a.cock@googlemail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hmm. Do you need this to work on Python 2?<br>
<br>
<a href="https://docs.python.org/2/library/urllib.html" rel="noreferrer" target="_blank">https://docs.python.org/2/<wbr>library/urllib.html</a><br>
<a href="https://docs.python.org/3/library/urllib.request.html" rel="noreferrer" target="_blank">https://docs.python.org/3/<wbr>library/urllib.request.html</a><br>
<br>
Python 3 added a timeout argument to the urlopen function,<br>
which it says defaults to the "global default timeout".<br>
<br>
Does this help:<br>
<br>
import socket<br>
socket.setdefaulttimeout(30)  # timeout in seconds<br>
<br>
I'm guessing at a sensible limit here - you will<br>
probably need to experiment.<br>
<br>
Regards,<br>
<br>
Peter<br>
<div><div class="h5"><br>
On Wed, Jul 26, 2017 at 12:26 PM, Pejvak Moghimi<br>
<<a href="mailto:pejvak.moghimi@york.ac.uk">pejvak.moghimi@york.ac.uk</a>> wrote:<br>
> Hi all,<br>
><br>
> I'm working on a script to to do blast using the ncbiWWW module, but very<br>
> often one query sequence takes way too long, if at all, to return with<br>
> results. This is always, in my experience, immediately solved if I just stop<br>
> the script and re-run it (for the same query sequence); I get the results as<br>
> quickly as I did for the other query sequences.<br>
><br>
> I think this hints that this is something to do with ncbi servers. So, in<br>
> order to tackle it, I need to simply modify my while loop to stop and re-run<br>
> the "ncbiwww.qblast(..." line, if it takes longer than a reasonable length<br>
> of time (I do understand shorter than a certain waiting-time would not be<br>
> allowed by ncbi).<br>
><br>
> I have no idea how to tackle this, except by either multithreading (not so<br>
> sure how to go on about this though) or changing the qblast script (locally<br>
> of course).<br>
><br>
> I would really appreciate any help. Please do let me know if you would like<br>
> to have a look at the script.<br>
><br>
> Cheers,<br>
> Pej.<br>
><br>
</div></div>> ______________________________<wbr>_________________<br>
> Biopython mailing list  -  <a href="mailto:Biopython@mailman.open-bio.org">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/<wbr>mailman/listinfo/biopython</a><br>
</blockquote></div><br></div>