|
|
@ -12,6 +12,7 @@ |
|
|
|
# See the License for the specific language governing permissions and |
|
|
|
# See the License for the specific language governing permissions and |
|
|
|
# limitations under the License. |
|
|
|
# limitations under the License. |
|
|
|
"""Invocation-side implementation of gRPC Asyncio Python.""" |
|
|
|
"""Invocation-side implementation of gRPC Asyncio Python.""" |
|
|
|
|
|
|
|
|
|
|
|
import asyncio |
|
|
|
import asyncio |
|
|
|
import sys |
|
|
|
import sys |
|
|
|
from typing import Any, AsyncIterable, Iterable, Optional, Sequence |
|
|
|
from typing import Any, AsyncIterable, Iterable, Optional, Sequence |
|
|
@ -357,14 +358,17 @@ class Channel: |
|
|
|
call_tasks = [] |
|
|
|
call_tasks = [] |
|
|
|
for task in tasks: |
|
|
|
for task in tasks: |
|
|
|
stack = task.get_stack(limit=1) |
|
|
|
stack = task.get_stack(limit=1) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# If the Task is created by a C-extension, the stack will be empty. |
|
|
|
if not stack: |
|
|
|
if not stack: |
|
|
|
continue |
|
|
|
continue |
|
|
|
|
|
|
|
|
|
|
|
# Locate ones created by `aio.Call`. |
|
|
|
# Locate ones created by `aio.Call`. |
|
|
|
frame = stack[0] |
|
|
|
frame = stack[0] |
|
|
|
if 'self' in frame.f_locals: |
|
|
|
candidate = frame.f_locals.get('self') |
|
|
|
if isinstance(frame.f_locals['self'], _base_call.Call): |
|
|
|
if candidate: |
|
|
|
calls.append(frame.f_locals['self']) |
|
|
|
if isinstance(candidate, _base_call.Call): |
|
|
|
|
|
|
|
calls.append(candidate) |
|
|
|
call_tasks.append(task) |
|
|
|
call_tasks.append(task) |
|
|
|
|
|
|
|
|
|
|
|
# If needed, try to wait for them to finish. |
|
|
|
# If needed, try to wait for them to finish. |
|
|
|