MCPcopy Index your code
hub / github.com/MongoEngine/mongoengine / run_in_thread

Method run_in_thread

tests/test_context_managers.py:190–204  ·  view source on GitHub ↗
(id)

Source from the content-addressed store, hash-verified

188 Group(ref=user).save()
189
190 def run_in_thread(id):
191 time.sleep(random.uniform(0.1, 0.5)) # Force desync of threads
192 if id % 2 == 0:
193 with no_dereference(Group):
194 for i in range(20):
195 time.sleep(random.uniform(0.1, 0.5))
196 assert Group.ref._auto_dereference is False
197 group = Group.objects.first()
198 assert isinstance(group.ref, DBRef)
199 else:
200 for i in range(20):
201 time.sleep(random.uniform(0.1, 0.5))
202 assert Group.ref._auto_dereference is True
203 group = Group.objects.first()
204 assert isinstance(group.ref, User)
205
206 threads = [
207 TestableThread(target=run_in_thread, args=(id,)) for id in range(100)

Callers

nothing calls this directly

Calls 2

no_dereferenceFunction · 0.90
firstMethod · 0.45

Tested by

no test coverage detected