How to use __patch method in yandex-tank

Best Python code snippet using yandex-tank

patch.py

Source:patch.py Github

copy

Full Screen

...14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.15# See the License for the specific language governing permissions and16# limitations under the License.17from CodernityDB.misc import NONE18def __patch(obj, name, new):19 n = NONE()20 orig = getattr(obj, name, n)21 if orig is not n:22 if orig == new:23 raise Exception("Shouldn't happen, new and orig are the same")24 setattr(obj, name, new)25 return26def patch_cache_lfu(lock_obj):27 """28 Patnches cache mechanizm to be thread safe (gevent ones also)29 .. note::30 It's internal CodernityDB mechanizm, it will be called when needed31 """32 import lfu_cache33 import lfu_cache_with_lock34 lfu_lock1lvl = lfu_cache_with_lock.create_cache1lvl(lock_obj)35 lfu_lock2lvl = lfu_cache_with_lock.create_cache2lvl(lock_obj)36 __patch(lfu_cache, 'cache1lvl', lfu_lock1lvl)37 __patch(lfu_cache, 'cache2lvl', lfu_lock2lvl)38def patch_cache_rr(lock_obj):39 """40 Patches cache mechanizm to be thread safe (gevent ones also)41 .. note::42 It's internal CodernityDB mechanizm, it will be called when needed43 """44 import rr_cache45 import rr_cache_with_lock46 rr_lock1lvl = rr_cache_with_lock.create_cache1lvl(lock_obj)47 rr_lock2lvl = rr_cache_with_lock.create_cache2lvl(lock_obj)48 __patch(rr_cache, 'cache1lvl', rr_lock1lvl)49 __patch(rr_cache, 'cache2lvl', rr_lock2lvl)50def patch_flush_fsync(db_obj):51 """52 Will always execute index.fsync after index.flush.53 .. note::54 It's for advanced users, use when you understand difference between `flush` and `fsync`, and when you definitely need that.55 It's important to call it **AFTER** database has all indexes etc (after db.create or db.open)56 Example usage::57 ...58 db = Database('/tmp/patch_demo')59 db.create()60 patch_flush_fsync(db)61 ...62 """63 def always_fsync(ind_obj):...

Full Screen

Full Screen

__init__.py

Source:__init__.py Github

copy

Full Screen

...3A package that gives you info on oodles of bitcoin pools4"""5from version import __version__6local_api = None7def __patch():8 """9 Extremely magical gevent deffering patch10 """11 global local_api12 if not local_api:13 import gevent.monkey14 gevent.monkey.patch_all(thread = False, time=False)15 import api16 local_api = api.API()17 18def add_pools(filenames):19 """20 Adds pools defined by their filenames21 """22 __patch()23 local_api.add_pools(filenames)24def get_coins():25 """26 Returns a set of coin objects.27 x.fields describes existing fields28 """29 __patch()30 return local_api.get_coins()31 32def get_pools():33 """34 Returns a set of Pool objects.35 x.fields describes existing fields36 """37 __patch()38 return local_api.get_pools()39 40def get_pool(name):41 """42 Returns a matching pool with the name43 Otherwise returns None44 """45 __patch()46 item = filter(lambda x: x.name == name, local_api.get_pools())47 if item == []:48 return None49 return item[0]50 51def get_difficulty(coin):52 """53 Returns the difficulty of a coin54 """55 __patch()56 return local_api.get_difficulty(coin)57 58def get_exchange(coin):59 """60 Returns the exchange rate for the coin61 """62 __patch()63 return local_api.get_exchange(coin)64 ...

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 yandex-tank 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