hi there, folks:
I'd really like to release 0.7.0 but I would like it to be at least a
little bit tested before I do so. Could those of you with CVS trees check
everything out and see if it performs as advertised? Deeper bugs than
that will have to wait for the next release, but I'd at least like to know
if it works for someone other than me.
______ __ __ _____ _ _
| ____ | \_/ |_____] |_____|
|_____| |_____ | | | |
@ t w i s t e d m a t r i x . c o m
I've noticed that code coverage doesn't appear to be recorded when code
is executed in something that has been deferToThread'ed.
Is this a known issue? Does anyone have an explanation?
I'm sure I'm overlooking something obvious here but I just can't get my
head around it.
Here's the setup: twisted.web server that generates dynamic content. Child
that serves up static content, e.g. css and favoicon. However, the static
content isn't making it. Instead, any hit to localhost/static actually
yields up a copy of / again.
Here's the server code
from twisted.internet import reactor, endpoints
from twisted.web import server
from twisted.web.resource import Resource
from twisted.web.static import File
content = """
<link rel="stylesheet" href="/static/test.css" type="text/css" />
<span class='twistedTest'>This</span> is a test
isLeaf = True
def render_GET(self, request):
return bytes(content, "utf-8")
if __name__ == "__main__":
root = tServer()
site = server.Site(root)
endpoint = endpoints.TCP4ServerEndpoint(reactor, 8080)
It's run with the command 'python tserver.py'. The expectation is that
what is inside the custom <span> will be red.
In the same dir as the script is a subdir 'static' with the css file inside
If I replace 'root' with root = Resource() then / doesn't serve up
anything, but /static is a directory listing of the static directory.
The dynamic server is basically a copy of several tutorials cooked down to
something that I could use to demonstrate the problem.
What am I missing here? /headscratch
Forgot to include the list in my reply...
On 23/11/2018 22:27, Chris Withers wrote:
> On 23/11/2018 22:22, Glyph wrote:
>>> On Nov 23, 2018, at 7:58 AM, Chris Withers <chris(a)withers.org> wrote:
>>> Hi All,
>>> Does trial do anything to clean up stuff that's been passed to
>> Nope. It does its best to clean up stuff that it knows is "in" the
>> reactor (sockets, timers, and the like), but since threads can kind
>> of do ~whatever~ there hasn't been support for that.
> Actually, looks like there's stuff in trial's Janitor class, but it
> only kicks in after the suite is finished, and I'm seeing leakage
> between tests within a suite...
>> deferToThread is a bit of a special case and you make a good point
>> here: there should probably be special support for it in trial.
> ...which I plan to add in carly in the meantime: basically block with
> a timeout on everything in the threadpool finishing it's work.
> Speaking of which, I'm happy with how carly is turning out, but would
> still welcome feedback, particularly on how the tests suites feel:
> Just don't read hook.py unless you like head-bendy code ;-)
Okay, so here's what I came up with
I'm not a fan of the sleep / busy loop pattern, but twisted makes it
prettymuch impossible to get hold of the ThreadWorkers queue, so that I
could block on them in this method. Any ideas on improvements would be
Does trial do anything to clean up stuff that's been passed to
I'm seeing what looks like leakage between tests where stuff that is
deferred to a thread from a LoopingCall is resulting in a DelayedCall
ending up in the reactor for the next test.
Does that ring any bells?