MCPcopy
hub / github.com/HelloZeroNet/ZeroNet / asyncWrapper

Method asyncWrapper

src/Ui/UiWebsocket.py:184–199  ·  view source on GitHub ↗
(self, func)

Source from the content-addressed store, hash-verified

182 return permissions
183
184 def asyncWrapper(self, func):
185 def asyncErrorWatcher(func, *args, **kwargs):
186 try:
187 result = func(*args, **kwargs)
188 if result is not None:
189 self.response(args[0], result)
190 except Exception as err:
191 if config.debug: # Allow websocket errors to appear on /Debug
192 import main
193 main.DebugHook.handleError()
194 self.log.error("WebSocket handleRequest error: %s" % Debug.formatException(err))
195 self.cmd("error", "Internal error: %s" % Debug.formatException(err, "html"))
196
197 def wrapper(*args, **kwargs):
198 gevent.spawn(asyncErrorWatcher, func, *args, **kwargs)
199 return wrapper
200
201 def getCmdFuncName(self, cmd):
202 func_name = "action" + cmd[0].upper() + cmd[1:]

Callers 1

handleRequestMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected