From 0837c8dd8860cfbcd3e179badd5b1ded1593ddd9 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Tue, 4 Aug 2020 10:30:38 +0100 Subject: [PATCH] defer reactor import in twisted.web.xmlrpc --- src/twisted/web/newsfragments/9931.bugfix | 1 + src/twisted/web/xmlrpc.py | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 src/twisted/web/newsfragments/9931.bugfix diff --git a/src/twisted/web/newsfragments/9931.bugfix b/src/twisted/web/newsfragments/9931.bugfix new file mode 100644 index 00000000000..f25667deba0 --- /dev/null +++ b/src/twisted/web/newsfragments/9931.bugfix @@ -0,0 +1 @@ +defer reactor import in twisted.web.xmlrpc diff --git a/src/twisted/web/xmlrpc.py b/src/twisted/web/xmlrpc.py index a5f21079222..1ef873cfd8b 100644 --- a/src/twisted/web/xmlrpc.py +++ b/src/twisted/web/xmlrpc.py @@ -22,7 +22,7 @@ # Sibling Imports from twisted.web import resource, server, http -from twisted.internet import defer, protocol, reactor, error +from twisted.internet import defer, protocol, error from twisted.python import reflect, failure from twisted.logger import Logger @@ -527,7 +527,7 @@ def __init__( allowNone=False, useDateTime=False, connectTimeout=30.0, - reactor=reactor, + reactor=None, ): """ @param url: The URL to which to post method calls. Calls will be made @@ -537,6 +537,9 @@ def __init__( @type url: L{bytes} """ + if reactor is None: + from twisted.internet import reactor + scheme, netloc, path, params, query, fragment = urlparse(url) netlocParts = netloc.split(b"@") if len(netlocParts) == 2: