[IMP] Convert: two minor typos and tab expansion.
bzr revid: p_christ@hol.gr-20091027201244-1qiwghq61o3a6cq8
This commit is contained in:
parent
870afd7445
commit
6affaee1ab
|
@ -37,13 +37,16 @@ class TinySocketClientThread(threading.Thread, netsvc.OpenERPDispatcher):
|
|||
self.sock = sock
|
||||
self.threads = threads
|
||||
|
||||
def __del__(self):
|
||||
if self.sock:
|
||||
self.sock.close()
|
||||
|
||||
def run(self):
|
||||
import select
|
||||
self.running = True
|
||||
try:
|
||||
ts = tiny_socket.mysocket(self.sock)
|
||||
except:
|
||||
self.sock.close()
|
||||
self.threads.remove(self)
|
||||
return False
|
||||
while self.running:
|
||||
|
@ -51,16 +54,25 @@ class TinySocketClientThread(threading.Thread, netsvc.OpenERPDispatcher):
|
|||
msg = ts.myreceive()
|
||||
except:
|
||||
self.sock.close()
|
||||
self.sock = None
|
||||
self.threads.remove(self)
|
||||
return False
|
||||
try:
|
||||
result = self.dispatch(msg[0], msg[1], msg[2:])
|
||||
ts.mysend(result)
|
||||
except netsvc.OpenERPDispatcherException, e:
|
||||
try:
|
||||
new_e = Exception(tools.exception_to_unicode(e.exception)) # avoid problems of pickeling
|
||||
ts.mysend(new_e, exception=True, traceback=e.traceback)
|
||||
except:
|
||||
pass
|
||||
except Exception, e:
|
||||
# this code should not be reachable, therefore we warn
|
||||
netsvc.Logger().notifyChannel("net-rpc", netsvc.LOG_WARNING, "exception: %" % str(e))
|
||||
break
|
||||
|
||||
self.sock.close()
|
||||
self.sock = None
|
||||
self.threads.remove(self)
|
||||
return True
|
||||
|
||||
|
@ -91,8 +103,16 @@ class TinySocketServerThread(threading.Thread,netsvc.Server):
|
|||
ct = TinySocketClientThread(clientsocket, self.threads)
|
||||
self.threads.append(ct)
|
||||
ct.start()
|
||||
lt = len(self.threads)
|
||||
if (lt > 10) and (lt % 10 == 0):
|
||||
# Not many threads should be serving at the same time, so log
|
||||
# their abuse.
|
||||
netsvc.Logger().notifyChannel("web-services", netsvc.LOG_DEBUG,
|
||||
"Netrpc: %d threads" % len(self.threads))
|
||||
self.socket.close()
|
||||
except Exception, e:
|
||||
netsvc.Logger().notifyChannel("web-services", netsvc.LOG_WARNING,
|
||||
"Netrpc: closing because of exception %s" % str(e))
|
||||
self.socket.close()
|
||||
return False
|
||||
|
||||
|
|
|
@ -243,12 +243,12 @@ class xml_import(object):
|
|||
id = xml_id
|
||||
if '.' in xml_id:
|
||||
module, id = xml_id.split('.', 1)
|
||||
assert '.' not in id, """The ID reference "%s" must contains
|
||||
assert '.' not in id, """The ID reference "%s" must contain
|
||||
maximum one dot. They are used to refer to other modules ID, in the
|
||||
form: module.record_id""" % (xml_id,)
|
||||
if module != self.module:
|
||||
modcnt = self.pool.get('ir.module.module').search_count(self.cr, self.uid, ['&', ('name', '=', module), ('state', 'in', ['installed'])])
|
||||
assert modcnt == 1, """The ID "%s" refer to an uninstalled module""" % (xml_id,)
|
||||
assert modcnt == 1, """The ID "%s" refers to an uninstalled module""" % (xml_id,)
|
||||
|
||||
if len(id) > 64:
|
||||
self.logger.notifyChannel('init', netsvc.LOG_ERROR, 'id: %s is to long (max: 64)'% (id,))
|
||||
|
|
Loading…
Reference in New Issue