@@ -85,15 +85,6 @@ def decorate(target):
85
85
import backoff ._async
86
86
retry = backoff ._async .retry_predicate
87
87
88
- elif _is_event_loop () and _is_current_task ():
89
- # Verify that sync version is not being run from coroutine
90
- # (that would lead to event loop hiccups).
91
- raise TypeError (
92
- "backoff.on_predicate applied to a regular function "
93
- "inside coroutine, this will lead to event loop "
94
- "hiccups. Use backoff.on_predicate on coroutines in "
95
- "asynchronous code." )
96
-
97
88
if retry is None :
98
89
retry = _sync .retry_predicate
99
90
@@ -174,14 +165,6 @@ def decorate(target):
174
165
if asyncio .iscoroutinefunction (target ):
175
166
import backoff ._async
176
167
retry = backoff ._async .retry_exception
177
- elif _is_event_loop () and _is_current_task ():
178
- # Verify that sync version is not being run from coroutine
179
- # (that would lead to event loop hiccups).
180
- raise TypeError (
181
- "backoff.on_exception applied to a regular function "
182
- "inside coroutine, this will lead to event loop "
183
- "hiccups. Use backoff.on_exception on coroutines in "
184
- "asynchronous code." )
185
168
186
169
if retry is None :
187
170
retry = _sync .retry_exception
@@ -193,25 +176,3 @@ def decorate(target):
193
176
194
177
# Return a function which decorates a target with a retry loop.
195
178
return decorate
196
-
197
-
198
- def _is_event_loop (): # pragma: no cover
199
- import asyncio
200
-
201
- try :
202
- if sys .version_info >= (3 , 7 ):
203
- asyncio .get_running_loop ()
204
-
205
- asyncio .get_event_loop ()
206
- except RuntimeError :
207
- return False
208
- else :
209
- return True
210
-
211
-
212
- def _is_current_task (): # pragma: no cover
213
- import asyncio
214
- if sys .version_info >= (3 , 7 ):
215
- return asyncio .current_task () is not None
216
-
217
- return asyncio .Task .current_task () is not None
0 commit comments