mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-03 03:44:52 -04:00
Port SyncHandler to async/await
This commit is contained in:
parent
d085a8a0a5
commit
8437e2383e
6 changed files with 182 additions and 191 deletions
|
@ -13,6 +13,7 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import inspect
|
||||
import logging
|
||||
from functools import wraps
|
||||
|
||||
|
@ -64,12 +65,22 @@ def measure_func(name=None):
|
|||
def wrapper(func):
|
||||
block_name = func.__name__ if name is None else name
|
||||
|
||||
@wraps(func)
|
||||
@defer.inlineCallbacks
|
||||
def measured_func(self, *args, **kwargs):
|
||||
with Measure(self.clock, block_name):
|
||||
r = yield func(self, *args, **kwargs)
|
||||
return r
|
||||
if inspect.iscoroutinefunction(func):
|
||||
|
||||
@wraps(func)
|
||||
async def measured_func(self, *args, **kwargs):
|
||||
with Measure(self.clock, block_name):
|
||||
r = await func(self, *args, **kwargs)
|
||||
return r
|
||||
|
||||
else:
|
||||
|
||||
@wraps(func)
|
||||
@defer.inlineCallbacks
|
||||
def measured_func(self, *args, **kwargs):
|
||||
with Measure(self.clock, block_name):
|
||||
r = yield func(self, *args, **kwargs)
|
||||
return r
|
||||
|
||||
return measured_func
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue