Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixes 'RuntimeError: thread already started'

  • Loading branch information...
commit f35bb3e12239d38e0925f3bd010244cc1a2338fe 1 parent 88ab2b4
@othrayte othrayte authored
Showing with 4 additions and 5 deletions.
  1. +4 −5 nbhttpconnection.py
View
9 nbhttpconnection.py
@@ -4,6 +4,7 @@
import os, sys
import time, socket
import urllib
+import thread
import threading
try:
@@ -28,14 +29,12 @@
__status__ = "Production"
# Allows non-blocking http requests
-class NBHTTPConnection(threading.Thread):
+class NBHTTPConnection():
def __init__(self, host, port = None, strict = None, timeout = None):
self.rawConnection = httplib.HTTPConnection(host, port, strict, timeout)
self.responce = None
self.responceLock = threading.Lock()
self.closing = False
-
- threading.Thread.__init__(self)
def request(self, method, url, body = None, headers = {}):
self.rawConnection.request(method, url, body, headers);
@@ -54,9 +53,9 @@ def getResult(self):
def go(self):
self.responceLock.acquire()
- self.start()
+ thread.start_new_thread ( NBHTTPConnection._run, ( self, ) )
- def run(self):
+ def _run(self):
self.responce = self.rawConnection.getresponse()
self.responceLock.release()
Please sign in to comment.
Something went wrong with that request. Please try again.