Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 23, 2017. It is now read-only.
/asyncioPublic archive

Commit99ebe37

Browse files
committed
Raise DeprecationWarning when run_in_executor is called with a Handle
(Closes issue#334)
1 parentb0e7438 commit99ebe37

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

‎asyncio/base_events.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,9 @@ def run_in_executor(self, executor, func, *args):
605605
ifisinstance(func,events.Handle):
606606
assertnotargs
607607
assertnotisinstance(func,events.TimerHandle)
608+
warnings.warn(
609+
"Passing Handle to loop.run_in_executor() is deprecated",
610+
DeprecationWarning)
608611
iffunc._cancelled:
609612
f=self.create_future()
610613
f.set_result(None)

‎tests/test_base_events.py‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,8 @@ def cb():
358358
h=asyncio.Handle(cb, (),self.loop)
359359
h.cancel()
360360

361-
f=self.loop.run_in_executor(None,h)
361+
withself.assertWarnsRegex(DeprecationWarning,"Passing Handle"):
362+
f=self.loop.run_in_executor(None,h)
362363
self.assertIsInstance(f,asyncio.Future)
363364
self.assertTrue(f.done())
364365
self.assertIsNone(f.result())
@@ -373,12 +374,14 @@ def cb():
373374

374375
self.loop.set_default_executor(executor)
375376

376-
res=self.loop.run_in_executor(None,h)
377+
withself.assertWarnsRegex(DeprecationWarning,"Passing Handle"):
378+
res=self.loop.run_in_executor(None,h)
377379
self.assertIs(f,res)
378380

379381
executor=mock.Mock()
380382
executor.submit.return_value=f
381-
res=self.loop.run_in_executor(executor,h)
383+
withself.assertWarnsRegex(DeprecationWarning,"Passing Handle"):
384+
res=self.loop.run_in_executor(executor,h)
382385
self.assertIs(f,res)
383386
self.assertTrue(executor.submit.called)
384387

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp