Move server.py into its own module (#2230)
* Move server.py into its own module * Change monkeypatch path on test_logging.py
This commit is contained in:
		
							
								
								
									
										16
									
								
								sanic/server/events.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								sanic/server/events.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,16 @@ | ||||
| from inspect import isawaitable | ||||
| from typing import Any, Callable, Iterable, Optional | ||||
|  | ||||
|  | ||||
| def trigger_events(events: Optional[Iterable[Callable[..., Any]]], loop): | ||||
|     """ | ||||
|     Trigger event callbacks (functions or async) | ||||
|  | ||||
|     :param events: one or more sync or async functions to execute | ||||
|     :param loop: event loop | ||||
|     """ | ||||
|     if events: | ||||
|         for event in events: | ||||
|             result = event(loop) | ||||
|             if isawaitable(result): | ||||
|                 loop.run_until_complete(result) | ||||
		Reference in New Issue
	
	Block a user
	 Adam Hopkins
					Adam Hopkins