Skip to content

Commit

Permalink
modify test code
Browse files Browse the repository at this point in the history
  • Loading branch information
bourbonkk committed Sep 11, 2023
1 parent 55f2325 commit d3facc4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


async def async_func():
await asyncio.sleep(1)
await asyncio.sleep(0.1)


async def factorial(name, number):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,16 @@ def tearDown(self):

def test_to_thread(self):
# to_thread is only available in Python 3.9+
def multiply(x, y):
return x * y
if sys.version_info >= (3, 9):
def multiply(x, y):
return x * y

async def to_thread():
result = await asyncio.to_thread(multiply, 2, 3)
assert result == 6
async def to_thread():
result = await asyncio.to_thread(multiply, 2, 3)
assert result == 6

asyncio.run(to_thread())
spans = self.memory_exporter.get_finished_spans()

asyncio.run(to_thread())
spans = self.memory_exporter.get_finished_spans()
if sys.version_info >= (3, 9):
self.assertEqual(len(spans), 1)
assert spans[0].name == "asyncio.to_thread_func-multiply"

0 comments on commit d3facc4

Please sign in to comment.