Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9202049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:09:59+00:00 2026-06-17T23:09:59+00:00

I have a long running process that crashes about every three days because during

  • 0

I have a long running process that crashes about every three days because during an HTTP connection, after the connection is made but before any data is received, httplib throws BadStatusLine. I’ve tried wrapping my call, but the exception just causes at stack trace and stops the process anyways.

#supporting code included for clarity
from httplib import BadStatusLine, HTTPException
import eventlet
sem = eventlet.semaphore.Semaphore(SIMULTENEOUS)

#problem code, running in one of many qthreads downloading various pages.
try:
    sem.acquire()
    eventlet.sleep(HIT_DELAY)
    lphtml = urllib2.urlopen(list_page_url).read()
    sem.release()
except (urllib2.URLError, urllib2.HTTPError, HTTPException, BadStatusLine) as e:
    sem.release()
    pipe.log.error("Could not download product list page %s\n%s" % (str(e), list_page_url))
    continue

I’m using a semaphore because I don’t want my code hitting the site more than once per second, (but I don’t want to git rid of eventlet for reasons elsewhere in the code.

Eventually the call to urllib2.urlopen will throw BadStatusLine, but it won’t be caught and the semaphore will never be released. This is the stack-trace produced.

Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/eventlet-0.9.16-py2.6.egg/eventlet/greenpool.py", line 80, in _spawn_n_impl
    func(*args, **kwargs)
  File "/home/myself/secret_filename.py", line 52, in poll_feed_hourly
    lphtml = urllib2.urlopen(list_page_url).read()
  File "/usr/lib/python2.6/urllib2.py", line 126, in urlopen
    return _opener.open(url, data, timeout)
  File "/usr/lib/python2.6/urllib2.py", line 391, in open
    response = self._open(req, data)
  File "/usr/lib/python2.6/urllib2.py", line 409, in _open
    '_open', req)
  File "/usr/lib/python2.6/urllib2.py", line 369, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.6/urllib2.py", line 1170, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "/usr/lib/python2.6/urllib2.py", line 1143, in do_open
    r = h.getresponse()
  File "/usr/lib/python2.6/httplib.py", line 990, in getresponse
    response.begin()
  File "/usr/lib/python2.6/httplib.py", line 391, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python2.6/httplib.py", line 355, in _read_status
    raise BadStatusLine(line)
BadStatusLine

Could it be my bizarre use of qthreads that causes BadStatusLine to never reach the catch statement? Is there some place I could insert a timeout to cause the except block to eventually be reached?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T23:10:00+00:00Added an answer on June 17, 2026 at 11:10 pm

    If the only problem is releasing the semaphore, why don’t you use the try/finally syntax?

    try:
        sem.acquire()
        eventlet.sleep(HIT_DELAY)
        lphtml = urllib2.urlopen(list_page_url).read()
    finally:
        sem.release()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a long-running process that must run every five minutes, but more than
I have a long running process that is called via a Nancy Module Get
I have a long running process that needs to do a lot of queries
I have a python web application that needs to launch a long running process.
I have a Perl script that executes a long running process and observes its
I have a long running process that allocates and releases objects constantly. Although objects
I am using ExtJS 3.4. I have a long running asynchronous process that I
I have a long running PHP process, that sometimes hangs in a loop. This
All, I have a long running process that I run on a background thread
I have a client that starts a long running process on the server. At

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.