Skip to content

Commit 9c26277

Browse files
committed
Avoid tight loop
1 parent 524de44 commit 9c26277

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

test/asynchronous/test_examples.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import functools
2121
import sys
2222
import threading
23+
import time
2324
from test.asynchronous.helpers import ConcurrentRunner
2425

2526
sys.path[0:0] = [""]
@@ -752,6 +753,7 @@ async def insert_docs():
752753
while not done:
753754
await db.inventory.insert_one({"username": "alice"})
754755
await db.inventory.delete_one({"username": "alice"})
756+
await asyncio.sleep(0.005)
755757

756758
t = ConcurrentRunner(target=insert_docs)
757759
await t.start()

test/test_examples.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import functools
2121
import sys
2222
import threading
23+
import time
2324
from test.helpers import ConcurrentRunner
2425

2526
sys.path[0:0] = [""]
@@ -752,6 +753,7 @@ def insert_docs():
752753
while not done:
753754
db.inventory.insert_one({"username": "alice"})
754755
db.inventory.delete_one({"username": "alice"})
756+
time.sleep(0.005)
755757

756758
t = ConcurrentRunner(target=insert_docs)
757759
t.start()

0 commit comments

Comments
 (0)