Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Poirier <theeth@yahoo.com>2011-11-12 20:57:05 +0400
committerMartin Poirier <theeth@yahoo.com>2011-11-12 20:57:05 +0400
commitfd753206a6db676b4604fda4349fc44083e9e2df (patch)
tree903655ddb927e851544bd6c0a50ffd75504ae1a1 /netrender/utils.py
parent271adef3807cf905c3727958a518268e288c4ebf (diff)
NetRender OS X bugfix
Fix for #26867 Hunted down and debugged with great help from Geoff Murphy
Diffstat (limited to 'netrender/utils.py')
-rw-r--r--netrender/utils.py35
1 files changed, 32 insertions, 3 deletions
diff --git a/netrender/utils.py b/netrender/utils.py
index 1ae60a20..5b8e1995 100644
--- a/netrender/utils.py
+++ b/netrender/utils.py
@@ -16,7 +16,7 @@
#
# ##### END GPL LICENSE BLOCK #####
-import sys, os, re
+import sys, os, re, platform
import http, http.client, http.server, socket
import subprocess, time, hashlib
@@ -57,6 +57,30 @@ FRAME_STATUS_TEXT = {
ERROR: "Error"
}
+if platform.system() == "Darwin":
+ class ConnectionContext:
+ def __init__(self, timeout = None):
+ self.old_timeout = socket.getdefaulttimeout()
+ self.timeout = timeout
+
+ def __enter__(self):
+ if self.old_timeout != self.timeout:
+ socket.setdefaulttimeout(self.timeout)
+ def __exit__(self, exc_type, exc_value, traceback):
+ if self.old_timeout != self.timeout:
+ socket.setdefaulttimeout(self.old_timeout)
+else:
+ # On sane OSes we can use the connection timeout value correctly
+ class ConnectionContext:
+ def __init__(self, timeout = None):
+ pass
+
+ def __enter__(self):
+ pass
+
+ def __exit__(self, exc_type, exc_value, traceback):
+ pass
+
class DirectoryContext:
def __init__(self, path):
self.path = path
@@ -146,7 +170,11 @@ def clientConnection(address, port, report = None, scan = True, timeout = 5):
return None
try:
- conn = http.client.HTTPConnection(address, port, timeout = timeout)
+ if platform.system() == "Darwin":
+ with ConnectionContext(timeout):
+ conn = http.client.HTTPConnection(address, port)
+ else:
+ conn = http.client.HTTPConnection(address, port, timeout = timeout)
if conn:
if clientVerifyVersion(conn):
@@ -163,7 +191,8 @@ def clientConnection(address, port, report = None, scan = True, timeout = 5):
return None
def clientVerifyVersion(conn):
- conn.request("GET", "/version")
+ with ConnectionContext():
+ conn.request("GET", "/version")
response = conn.getresponse()
if response.status != http.client.OK: