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
98ef9200
Kaydet (Commit)
98ef9200
authored
May 30, 2019
tarafından
Alex Grönholm
Kaydeden (comit)
Miss Islington (bot)
May 30, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-36999: Add asyncio.Task.get_coro() (GH-13680)
https://bugs.python.org/issue36999
üst
25ee0c3b
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
52 additions
and
1 deletion
+52
-1
asyncio-task.rst
Doc/library/asyncio-task.rst
+6
-0
tasks.py
Lib/asyncio/tasks.py
+3
-0
test_tasks.py
Lib/test/test_asyncio/test_tasks.py
+10
-0
2019-05-30-13-30-46.bpo-36999.EjY_L2.rst
...S.d/next/Library/2019-05-30-13-30-46.bpo-36999.EjY_L2.rst
+2
-0
_asynciomodule.c
Modules/_asynciomodule.c
+13
-0
_asynciomodule.c.h
Modules/clinic/_asynciomodule.c.h
+18
-1
No files found.
Doc/library/asyncio-task.rst
Dosyayı görüntüle @
98ef9200
...
@@ -842,6 +842,12 @@ Task Object
...
@@ -842,6 +842,12 @@ Task Object
The *file* argument is an I/O stream to which the output
The *file* argument is an I/O stream to which the output
is written; by default output is written to :data:`sys.stderr`.
is written; by default output is written to :data:`sys.stderr`.
.. method:: get_coro()
Return the coroutine object wrapped by the :class:`Task`.
.. versionadded:: 3.8
.. method:: get_name()
.. method:: get_name()
Return the name of the Task.
Return the name of the Task.
...
...
Lib/asyncio/tasks.py
Dosyayı görüntüle @
98ef9200
...
@@ -152,6 +152,9 @@ class Task(futures._PyFuture): # Inherit Python Task implementation
...
@@ -152,6 +152,9 @@ class Task(futures._PyFuture): # Inherit Python Task implementation
def
_repr_info
(
self
):
def
_repr_info
(
self
):
return
base_tasks
.
_task_repr_info
(
self
)
return
base_tasks
.
_task_repr_info
(
self
)
def
get_coro
(
self
):
return
self
.
_coro
def
get_name
(
self
):
def
get_name
(
self
):
return
self
.
_name
return
self
.
_name
...
...
Lib/test/test_asyncio/test_tasks.py
Dosyayı görüntüle @
98ef9200
...
@@ -2425,6 +2425,16 @@ class BaseTaskTests:
...
@@ -2425,6 +2425,16 @@ class BaseTaskTests:
self
.
assertEqual
(
cvar
.
get
(),
-
1
)
self
.
assertEqual
(
cvar
.
get
(),
-
1
)
def
test_get_coro
(
self
):
loop
=
asyncio
.
new_event_loop
()
coro
=
coroutine_function
()
try
:
task
=
self
.
new_task
(
loop
,
coro
)
loop
.
run_until_complete
(
task
)
self
.
assertIs
(
task
.
get_coro
(),
coro
)
finally
:
loop
.
close
()
def
add_subclass_tests
(
cls
):
def
add_subclass_tests
(
cls
):
BaseTask
=
cls
.
Task
BaseTask
=
cls
.
Task
...
...
Misc/NEWS.d/next/Library/2019-05-30-13-30-46.bpo-36999.EjY_L2.rst
0 → 100644
Dosyayı görüntüle @
98ef9200
Add the ``asyncio.Task.get_coro()`` method to publicly expose the tasks's
coroutine object.
Modules/_asynciomodule.c
Dosyayı görüntüle @
98ef9200
...
@@ -2313,6 +2313,18 @@ _asyncio_Task_set_exception(TaskObj *self, PyObject *exception)
...
@@ -2313,6 +2313,18 @@ _asyncio_Task_set_exception(TaskObj *self, PyObject *exception)
return
NULL
;
return
NULL
;
}
}
/*[clinic input]
_asyncio.Task.get_coro
[clinic start generated code]*/
static
PyObject
*
_asyncio_Task_get_coro_impl
(
TaskObj
*
self
)
/*[clinic end generated code: output=bcac27c8cc6c8073 input=d2e8606c42a7b403]*/
{
Py_INCREF
(
self
->
task_coro
);
return
self
->
task_coro
;
}
/*[clinic input]
/*[clinic input]
_asyncio.Task.get_name
_asyncio.Task.get_name
[clinic start generated code]*/
[clinic start generated code]*/
...
@@ -2439,6 +2451,7 @@ static PyMethodDef TaskType_methods[] = {
...
@@ -2439,6 +2451,7 @@ static PyMethodDef TaskType_methods[] = {
_ASYNCIO_TASK__REPR_INFO_METHODDEF
_ASYNCIO_TASK__REPR_INFO_METHODDEF
_ASYNCIO_TASK_GET_NAME_METHODDEF
_ASYNCIO_TASK_GET_NAME_METHODDEF
_ASYNCIO_TASK_SET_NAME_METHODDEF
_ASYNCIO_TASK_SET_NAME_METHODDEF
_ASYNCIO_TASK_GET_CORO_METHODDEF
{
NULL
,
NULL
}
/* Sentinel */
{
NULL
,
NULL
}
/* Sentinel */
};
};
...
...
Modules/clinic/_asynciomodule.c.h
Dosyayı görüntüle @
98ef9200
...
@@ -569,6 +569,23 @@ PyDoc_STRVAR(_asyncio_Task_set_exception__doc__,
...
@@ -569,6 +569,23 @@ PyDoc_STRVAR(_asyncio_Task_set_exception__doc__,
#define _ASYNCIO_TASK_SET_EXCEPTION_METHODDEF \
#define _ASYNCIO_TASK_SET_EXCEPTION_METHODDEF \
{"set_exception", (PyCFunction)_asyncio_Task_set_exception, METH_O, _asyncio_Task_set_exception__doc__},
{"set_exception", (PyCFunction)_asyncio_Task_set_exception, METH_O, _asyncio_Task_set_exception__doc__},
PyDoc_STRVAR
(
_asyncio_Task_get_coro__doc__
,
"get_coro($self, /)
\n
"
"--
\n
"
"
\n
"
);
#define _ASYNCIO_TASK_GET_CORO_METHODDEF \
{"get_coro", (PyCFunction)_asyncio_Task_get_coro, METH_NOARGS, _asyncio_Task_get_coro__doc__},
static
PyObject
*
_asyncio_Task_get_coro_impl
(
TaskObj
*
self
);
static
PyObject
*
_asyncio_Task_get_coro
(
TaskObj
*
self
,
PyObject
*
Py_UNUSED
(
ignored
))
{
return
_asyncio_Task_get_coro_impl
(
self
);
}
PyDoc_STRVAR
(
_asyncio_Task_get_name__doc__
,
PyDoc_STRVAR
(
_asyncio_Task_get_name__doc__
,
"get_name($self, /)
\n
"
"get_name($self, /)
\n
"
"--
\n
"
"--
\n
"
...
@@ -815,4 +832,4 @@ _asyncio__leave_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs,
...
@@ -815,4 +832,4 @@ _asyncio__leave_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs,
exit:
exit:
return
return_value
;
return
return_value
;
}
}
/*[clinic end generated code: output=
e3b02d96da56e80c
input=a9049054013a1b77]*/
/*[clinic end generated code: output=
51c50219f6a0863a
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