This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Puts code to sleep.

Overview

The narcolepsy package contains code which alters the behavior of your application/api by injecting random sleep calls into decorated functions.

Usage

The following code is an example of using the @narcoleptic decorator.

from narcolepsy import narcoleptic

@narcoleptic(max=5)  # sleep for 5 seconds at max
def foobar():
    for x in xrange(1024):
        nested_function(x)

The @narcoleptic decorator takes three parameters (all optional):

  • min: The minimum sleep time in seconds.
  • max: The maximum sleep time in seconds.
  • chance: The maximum number of lines that will be executed before a sleep() call is injected.

If no min or max are passed in, the constants defined in narcolepsy.constants will be used instead. If no chance is passed in, a value will be derived from the number of lines in the input function.

Installation

The easiest way to install narcolepsy is via pip:

$ pip install narcolepsy

Known Issues

As mentioned in the official documentation, sys.settrace() isn’t part of the Python language definition and thus, may not be available to all Python implementations.

Why?

In theory this could help test time-critical code (multi-producer/consumer concurrent applications), but I mostly just wanted to play around with line tracers.

Disclaimer

This is a proof of concept and probably shouldn’t be used in any sort of real-world scenario where testing of time-critical code has any measure of importance. USE AT YOUR OWN RISK!

LICENSE

See the LICENSE file for details.

Release History

Release History

0.0.3

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
narcolepsy-0.0.3.tar.gz (4.4 kB) Copy SHA256 Checksum SHA256 Source Aug 22, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting