Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
gevent coverage is broken
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jamie C  
View profile  
 More options Apr 27 2012, 2:09 pm
From: Jamie C <jamie.cyb...@gmail.com>
Date: Fri, 27 Apr 2012 11:09:07 -0700 (PDT)
Local: Fri, Apr 27 2012 2:09 pm
Subject: gevent coverage is broken
Hi,

We ran coverage with gevent and noticed when there's a context switch
in a function, the lower half of the function is reported uncovered
although it is executed later.

For example, running the sample code below with coverage, it will
report the 'print' line is not executed in coverage.

#!/usr/bin/python
# Copyright (c) 2009 Denis Bilenko. See LICENSE for details.

"""Spawn multiple workers and wait for them to complete"""

urls = ['http://www.google.com', 'http://www.yandex.ru', 'http://
www.python.org']

import gevent
from gevent import monkey

# patches stdlib (including socket and ssl modules) to cooperate with
other greenlets
monkey.patch_all()

import urllib2

def print_head(url):
    print ('Starting %s' % url)
    data = urllib2.urlopen(url).read()
    print ('%s: %s bytes: %r' % (url, len(data), data[:50]))

jobs = [gevent.spawn(print_head, url) for url in urls]

gevent.joinall(jobs)

Gleaned from the coverage blog, briefly coverage.py works by:
Python provides a trace feature: you register a function with
sys.settrace(), and it is called as code is executed. It is passed an
event argument indicating what happened: "call" for entering a new
scope, "return" for leaving a scope, "line" for a line of code
executed, and "exception" for an exception being raised.

Can someone shed some light on this?

Also reported this issue on coverage at:
https://bitbucket.org/ned/coveragepy/issue/177/strange-coverage-results

Thanks!

Jamie


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »