How to use _release_recv_lock method in fMBT

Best Python code snippet using fMBT_python

__init__.py

Source:__init__.py Github

copy

Full Screen

...138 except Exception, e:139 return messages.Unloadable("load error %s: %s" % (type(e).__name__, e))140 finally:141 if acquire_recv_lock:142 _release_recv_lock(source)143_recv.locks = {}144def _recv_with_info(source, acquire_recv_lock=True):145 """returns the first payload message from source that may/may not be146 preceded by Data_info147 """148 if acquire_recv_lock:149 _acquire_recv_lock(source)150 try:151 msg = _recv(source, False)152 if not isinstance(msg, messages.Data_info):153 return msg154 data = source.read(msg.data_length)155 if len(data) != msg.data_length:156 raise EOFError()157 if "compressed(" in msg.data_format:158 data = zlib.decompress(data)159 try:160 return cPickle.loads(data)161 except (ValueError, cPickle.UnpicklingError), e:162 return messages.Unloadable(str(e))163 except Exception, e:164 return messages.Unloadable("load error %s: %s" % (type(e).__name__, e))165 finally:166 if acquire_recv_lock:167 _release_recv_lock(source)168def _forward(source, destination, data_length,169 acquire_send_lock=True,170 acquire_recv_lock=True):171 if acquire_recv_lock:172 _acquire_recv_lock(source)173 if acquire_send_lock:174 _acquire_send_lock(destination)175 destination_ok = True176 try:177 bytes_sent = 0178 bytes_read = 0179 forward_block_size = _SEND_OPT_BLOCK_SIZE180 while bytes_read < data_length:181 forward_block = source.read(182 min(forward_block_size, data_length - bytes_read))183 bytes_read += len(forward_block)184 if forward_block:185 if destination_ok:186 try:187 destination.write(forward_block)188 destination.flush()189 bytes_sent += len(forward_block)190 except socket.error:191 destination_ok = False192 # must still keep reading everything from the source193 else:194 raise EOFError() # source run out of data195 return bytes_sent196 finally:197 if acquire_recv_lock:198 _release_recv_lock(source)199 if acquire_send_lock:200 _release_send_lock(destination)201def _acquire_recv_lock(source):202 if not source in _recv.locks:203 _recv.locks[source] = thread.allocate_lock()204 _recv.locks[source].acquire()205def _acquire_send_lock(destination):206 if not destination in _send.locks:207 _send.locks[destination] = thread.allocate_lock()208 _send.locks[destination].acquire()209def _release_recv_lock(source):210 try:211 _recv.locks[source].release()212 except thread.error:213 pass # already released214def _release_send_lock(destination):215 try:216 _send.locks[destination].release()217 except thread.error:218 pass # already released219_g_hooks = {}220def _check_hook(signature, context):221 """Check if callbacks have been registered for a signature.222 If so, call them with the context"""223 if _g_hooks and signature in _g_hooks:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fMBT automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful