Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
13802a3b
Kaydet (Commit)
13802a3b
authored
Mar 03, 2017
tarafından
Yury Selivanov
Kaydeden (comit)
Yury Selivanov
Mar 03, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-29271: Fix Task.current_task and Task.all_tasks to accept None. (#406)
üst
dea5101a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
11 deletions
+31
-11
test_tasks.py
Lib/test/test_asyncio/test_tasks.py
+17
-0
NEWS
Misc/NEWS
+3
-0
_asynciomodule.c
Modules/_asynciomodule.c
+8
-8
_asynciomodule.c.h
Modules/clinic/_asynciomodule.c.h
+3
-3
No files found.
Lib/test/test_asyncio/test_tasks.py
Dosyayı görüntüle @
13802a3b
...
@@ -1462,6 +1462,14 @@ class BaseTaskTests:
...
@@ -1462,6 +1462,14 @@ class BaseTaskTests:
def
coro
(
loop
):
def
coro
(
loop
):
self
.
assertTrue
(
Task
.
current_task
(
loop
=
loop
)
is
task
)
self
.
assertTrue
(
Task
.
current_task
(
loop
=
loop
)
is
task
)
# See http://bugs.python.org/issue29271 for details:
asyncio
.
set_event_loop
(
loop
)
try
:
self
.
assertIs
(
Task
.
current_task
(
None
),
task
)
self
.
assertIs
(
Task
.
current_task
(),
task
)
finally
:
asyncio
.
set_event_loop
(
None
)
task
=
self
.
new_task
(
self
.
loop
,
coro
(
self
.
loop
))
task
=
self
.
new_task
(
self
.
loop
,
coro
(
self
.
loop
))
self
.
loop
.
run_until_complete
(
task
)
self
.
loop
.
run_until_complete
(
task
)
self
.
assertIsNone
(
Task
.
current_task
(
loop
=
self
.
loop
))
self
.
assertIsNone
(
Task
.
current_task
(
loop
=
self
.
loop
))
...
@@ -1806,8 +1814,17 @@ class BaseTaskTests:
...
@@ -1806,8 +1814,17 @@ class BaseTaskTests:
# schedule the task
# schedule the task
coro
=
kill_me
(
self
.
loop
)
coro
=
kill_me
(
self
.
loop
)
task
=
asyncio
.
ensure_future
(
coro
,
loop
=
self
.
loop
)
task
=
asyncio
.
ensure_future
(
coro
,
loop
=
self
.
loop
)
self
.
assertEqual
(
Task
.
all_tasks
(
loop
=
self
.
loop
),
{
task
})
self
.
assertEqual
(
Task
.
all_tasks
(
loop
=
self
.
loop
),
{
task
})
# See http://bugs.python.org/issue29271 for details:
asyncio
.
set_event_loop
(
self
.
loop
)
try
:
self
.
assertEqual
(
Task
.
all_tasks
(),
{
task
})
self
.
assertEqual
(
Task
.
all_tasks
(
None
),
{
task
})
finally
:
asyncio
.
set_event_loop
(
None
)
# execute the task so it waits for future
# execute the task so it waits for future
self
.
loop
.
_run_once
()
self
.
loop
.
_run_once
()
self
.
assertEqual
(
len
(
self
.
loop
.
_ready
),
0
)
self
.
assertEqual
(
len
(
self
.
loop
.
_ready
),
0
)
...
...
Misc/NEWS
Dosyayı görüntüle @
13802a3b
...
@@ -82,6 +82,9 @@ Extension Modules
...
@@ -82,6 +82,9 @@ Extension Modules
Library
Library
-------
-------
- bpo-29271: Fix Task.current_task and Task.all_tasks implemented in C
to accept None argument as their pure Python implementation.
- bpo-29703: Fix asyncio to support instantiation of new event loops
- bpo-29703: Fix asyncio to support instantiation of new event loops
in child processes.
in child processes.
...
...
Modules/_asynciomodule.c
Dosyayı görüntüle @
13802a3b
...
@@ -1413,7 +1413,7 @@ TaskObj_get_fut_waiter(TaskObj *task)
...
@@ -1413,7 +1413,7 @@ TaskObj_get_fut_waiter(TaskObj *task)
@classmethod
@classmethod
_asyncio.Task.current_task
_asyncio.Task.current_task
loop: 'O' = N
ULL
loop: 'O' = N
one
Return the currently running task in an event loop or None.
Return the currently running task in an event loop or None.
...
@@ -1424,12 +1424,12 @@ None is returned when called not in the context of a Task.
...
@@ -1424,12 +1424,12 @@ None is returned when called not in the context of a Task.
static
PyObject
*
static
PyObject
*
_asyncio_Task_current_task_impl
(
PyTypeObject
*
type
,
PyObject
*
loop
)
_asyncio_Task_current_task_impl
(
PyTypeObject
*
type
,
PyObject
*
loop
)
/*[clinic end generated code: output=99fbe7332c516e03 input=
cd784537f02cf833
]*/
/*[clinic end generated code: output=99fbe7332c516e03 input=
a0d6cdf2e3b243e1
]*/
{
{
PyObject
*
res
;
PyObject
*
res
;
if
(
loop
==
NULL
)
{
if
(
loop
==
Py_None
)
{
loop
=
PyObject_CallObject
(
asyncio_get_event_loop
,
NULL
);
loop
=
_PyObject_CallNoArg
(
asyncio_get_event_loop
);
if
(
loop
==
NULL
)
{
if
(
loop
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
...
@@ -1500,7 +1500,7 @@ fail:
...
@@ -1500,7 +1500,7 @@ fail:
@classmethod
@classmethod
_asyncio.Task.all_tasks
_asyncio.Task.all_tasks
loop: 'O' = N
ULL
loop: 'O' = N
one
Return a set of all tasks for an event loop.
Return a set of all tasks for an event loop.
...
@@ -1509,12 +1509,12 @@ By default all tasks for the current event loop are returned.
...
@@ -1509,12 +1509,12 @@ By default all tasks for the current event loop are returned.
static
PyObject
*
static
PyObject
*
_asyncio_Task_all_tasks_impl
(
PyTypeObject
*
type
,
PyObject
*
loop
)
_asyncio_Task_all_tasks_impl
(
PyTypeObject
*
type
,
PyObject
*
loop
)
/*[clinic end generated code: output=11f9b20749ccca5d input=c
d64aa5f88bd5c49
]*/
/*[clinic end generated code: output=11f9b20749ccca5d input=c
6f5b53bd487488f
]*/
{
{
PyObject
*
res
;
PyObject
*
res
;
if
(
loop
==
NULL
)
{
if
(
loop
==
Py_None
)
{
loop
=
PyObject_CallObject
(
asyncio_get_event_loop
,
NULL
);
loop
=
_PyObject_CallNoArg
(
asyncio_get_event_loop
);
if
(
loop
==
NULL
)
{
if
(
loop
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
...
...
Modules/clinic/_asynciomodule.c.h
Dosyayı görüntüle @
13802a3b
...
@@ -278,7 +278,7 @@ _asyncio_Task_current_task(PyTypeObject *type, PyObject **args, Py_ssize_t nargs
...
@@ -278,7 +278,7 @@ _asyncio_Task_current_task(PyTypeObject *type, PyObject **args, Py_ssize_t nargs
PyObject
*
return_value
=
NULL
;
PyObject
*
return_value
=
NULL
;
static
const
char
*
const
_keywords
[]
=
{
"loop"
,
NULL
};
static
const
char
*
const
_keywords
[]
=
{
"loop"
,
NULL
};
static
_PyArg_Parser
_parser
=
{
"|O:current_task"
,
_keywords
,
0
};
static
_PyArg_Parser
_parser
=
{
"|O:current_task"
,
_keywords
,
0
};
PyObject
*
loop
=
NULL
;
PyObject
*
loop
=
Py_None
;
if
(
!
_PyArg_ParseStack
(
args
,
nargs
,
kwnames
,
&
_parser
,
if
(
!
_PyArg_ParseStack
(
args
,
nargs
,
kwnames
,
&
_parser
,
&
loop
))
{
&
loop
))
{
...
@@ -310,7 +310,7 @@ _asyncio_Task_all_tasks(PyTypeObject *type, PyObject **args, Py_ssize_t nargs, P
...
@@ -310,7 +310,7 @@ _asyncio_Task_all_tasks(PyTypeObject *type, PyObject **args, Py_ssize_t nargs, P
PyObject
*
return_value
=
NULL
;
PyObject
*
return_value
=
NULL
;
static
const
char
*
const
_keywords
[]
=
{
"loop"
,
NULL
};
static
const
char
*
const
_keywords
[]
=
{
"loop"
,
NULL
};
static
_PyArg_Parser
_parser
=
{
"|O:all_tasks"
,
_keywords
,
0
};
static
_PyArg_Parser
_parser
=
{
"|O:all_tasks"
,
_keywords
,
0
};
PyObject
*
loop
=
NULL
;
PyObject
*
loop
=
Py_None
;
if
(
!
_PyArg_ParseStack
(
args
,
nargs
,
kwnames
,
&
_parser
,
if
(
!
_PyArg_ParseStack
(
args
,
nargs
,
kwnames
,
&
_parser
,
&
loop
))
{
&
loop
))
{
...
@@ -517,4 +517,4 @@ _asyncio_Task__wakeup(TaskObj *self, PyObject **args, Py_ssize_t nargs, PyObject
...
@@ -517,4 +517,4 @@ _asyncio_Task__wakeup(TaskObj *self, PyObject **args, Py_ssize_t nargs, PyObject
exit:
exit:
return
return_value
;
return
return_value
;
}
}
/*[clinic end generated code: output=
8f036321bb083066
input=a9049054013a1b77]*/
/*[clinic end generated code: output=
40ca6c9da517da73
input=a9049054013a1b77]*/
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment