from pprint import pprint
try:
- from threading import Thread, currentThread
+ from threading import Thread, current_thread
have_threads = 1
except ImportError:
have_threads = 0
from pprint import pprint
try:
- from threading import Thread, currentThread
+ from threading import Thread, current_thread
have_threads = 1
except ImportError:
have_threads = 0
import time
try:
- from threading import Thread, currentThread
+ from threading import Thread, current_thread
have_threads = 1
except ImportError:
have_threads = 0
deadlock_detection.end=False
deadlock_detection.count=0
t=Thread(target=deadlock_detection)
- t.setDaemon(True)
+ t.set_daemon(True)
t.start()
self.env.set_timeout(100000, db.DB_SET_LOCK_TIMEOUT)
anID = self.env.lock_id()
self.assertTrue(deadlock_detection.count>0)
def theThread(self, sleepTime, lockType):
- name = currentThread().getName()
+ name = current_thread().get_name()
if lockType == db.DB_LOCK_WRITE:
lt = "write"
else:
DASH = b'-'
try:
- from threading import Thread, currentThread
+ from threading import Thread, current_thread
have_threads = True
except ImportError:
have_threads = False
self._writerThread(*args, **kwargs)
except db.DBLockDeadlockError:
if verbose:
- print(currentThread().getName(), 'died from', e)
+ print(current_thread().get_name(), 'died from', e)
else:
if verbose:
- print(currentThread().getName(), "finished.")
+ print(current_thread().get_name(), "finished.")
def readerThread(self, *args, **kwargs):
try:
self._readerThread(*args, **kwargs)
except db.DBLockDeadlockError as e:
if verbose:
- print(currentThread().getName(), 'died from', e)
+ print(current_thread().get_name(), 'died from', e)
else:
if verbose:
- print(currentThread().getName(), "finished.")
+ print(current_thread().get_name(), "finished.")
t.join()
def _writerThread(self, d, howMany):
- name = currentThread().getName()
+ name = current_thread().get_name()
start = 0
stop = howMany
if verbose:
def _readerThread(self, d, readerNum):
time.sleep(0.01 * readerNum)
- name = currentThread().getName()
+ name = current_thread().get_name()
for loop in range(5):
c = d.cursor()
t.join()
def _writerThread(self, d, howMany, writerNum):
- name = currentThread().getName()
+ name = current_thread().get_name()
start = howMany * writerNum
stop = howMany * (writerNum + 1) - 1
if verbose:
def _readerThread(self, d, readerNum):
time.sleep(0.01 * readerNum)
- name = currentThread().getName()
+ name = current_thread().get_name()
for loop in range(5):
c = d.cursor()
time.sleep(0.05)
def _writerThread(self, d, howMany, writerNum):
- name = currentThread().getName()
+ name = current_thread().get_name()
start = howMany * writerNum
stop = howMany * (writerNum + 1) - 1
if verbose:
def _readerThread(self, d, readerNum):
time.sleep(0.01 * readerNum + 0.05)
- name = currentThread().getName()
+ name = current_thread().get_name()
for loop in range(5):
finished = False
erf = sys.__stderr__
print('\n' + '-'*40, file=erf)
print('Unhandled server exception!', file=erf)
- print('Thread: %s' % threading.currentThread().getName(), file=erf)
+ print('Thread: %s' % threading.current_thread().get_name(), file=erf)
print('Client Address: ', client_address, file=erf)
print('Request: ', repr(request), file=erf)
traceback.print_exc(file=erf)
nextseq = 0
def __init__(self, sock, objtable=None, debugging=None):
- self.sockthread = threading.currentThread()
+ self.sockthread = threading.current_thread()
if debugging is not None:
self.debugging = debugging
self.sock = sock
def debug(self, *args):
if not self.debugging:
return
- s = self.location + " " + str(threading.currentThread().getName())
+ s = self.location + " " + str(threading.current_thread().getName())
for a in args:
s = s + " " + str(a)
print(s, file=sys.__stderr__)
def asynccall(self, oid, methodname, args, kwargs):
request = ("CALL", (oid, methodname, args, kwargs))
seq = self.newseq()
- if threading.currentThread() != self.sockthread:
+ if threading.current_thread() != self.sockthread:
cvar = threading.Condition()
self.cvars[seq] = cvar
self.debug(("asynccall:%d:" % seq), oid, methodname, args, kwargs)
def asyncqueue(self, oid, methodname, args, kwargs):
request = ("QUEUE", (oid, methodname, args, kwargs))
seq = self.newseq()
- if threading.currentThread() != self.sockthread:
+ if threading.current_thread() != self.sockthread:
cvar = threading.Condition()
self.cvars[seq] = cvar
self.debug(("asyncqueue:%d:" % seq), oid, methodname, args, kwargs)
def _getresponse(self, myseq, wait):
self.debug("_getresponse:myseq:", myseq)
- if threading.currentThread() is self.sockthread:
+ if threading.current_thread() is self.sockthread:
# this thread does all reading of requests or responses
while 1:
response = self.pollresponse(myseq, wait)
sockthread = threading.Thread(target=manage_socket,
name='SockThread',
args=((LOCALHOST, port),))
- sockthread.setDaemon(True)
+ sockthread.set_daemon(True)
sockthread.start()
while 1:
try:
erf = sys.__stderr__
print('\n' + '-'*40, file=erf)
print('Unhandled server exception!', file=erf)
- print('Thread: %s' % threading.currentThread().getName(), file=erf)
+ print('Thread: %s' % threading.current_thread().get_name(), file=erf)
print('Client Address: ', client_address, file=erf)
print('Request: ', repr(request), file=erf)
traceback.print_exc(file=erf)
t = threading.Thread(target = self.process_request_thread,
args = (request, client_address))
if self.daemon_threads:
- t.setDaemon (1)
+ t.set_daemon(True)
t.start()
t.join()
ok += t.ok_count
if t.error_count:
- errors.append(str(t.getName()) + str(t.errors.getvalue()))
+ errors.append(str(t.get_name()) + str(t.errors.getvalue()))
threading_cleanup(*thread_info)
P = []
for i in range(NP):
t = ProducerThread(Q, NI)
- t.setName("Producer-%d" % (i+1))
+ t.set_name("Producer-%d" % (i+1))
P.append(t)
C = ConsumerThread(Q, NI*NP)
for t in P: