# HG changeset patch # User Martin Bornhold # Date 2016-07-05 07:37:13 # Node ID 4f555b5539b6930f7364de22e830d4f39b3360a9 # Parent d5c4e7ee138a352bf147059df767c39fe5d08baf pyro: Return new proxy instances if called from outside of a request context. This allows to run code that uses the pyro connection to the VCSServer but does not execute from within a request context, e.g. invoke tasks. diff --git a/rhodecode/lib/vcs/client.py b/rhodecode/lib/vcs/client.py --- a/rhodecode/lib/vcs/client.py +++ b/rhodecode/lib/vcs/client.py @@ -214,7 +214,16 @@ class RequestScopeProxyFactory(object): """ Call this to get the pyro proxy instance for the request. """ - # Return already borrowed proxy for this request + + # If called without a request context we return new proxy instances + # on every call. This allows to run e.g. invoke tasks. + if request is None: + log.info('Creating pyro proxy without request context for ' + 'remote_uri=%s', self._remote_uri) + return Pyro4.Proxy(self._remote_uri) + + # If there is an already borrowed proxy for the request context we + # return that instance instead of creating a new one. if request in self._borrowed_proxies: return self._borrowed_proxies[request]