Download Shareware and Freeware Software for Windows, Linux, Macintosh, PDA

line Home  |  About Us  |  Link To Us  |  FAQ  |  Contact

Serving Software Downloads in 976 Categories, Downloaded 29.625.703 Times

multitask 0.2.0

  Date Added: June 11, 2010  |  Visits: 753

multitask

Report Broken Link
Printer Friendly Version


Product Homepage
Download (73 downloads)



multitask allows Python programs to use generators (aka coroutines) to perform cooperative multitasking and asynchronous I/O. Applications written using multitask consist of a set of cooperating tasks that yield to a shared task manager whenever they perform a (potentially) blocking operation, such as I/O on a socket or getting data from a queue. The task manager temporarily suspends the task (allowing other tasks to run in the meantime) and then restarts it when the blocking operation is complete. Such an approach is suitable for applications that would otherwise have to use select() and/or multiple threads to achieve concurrency. This project is free software, distributed under the MIT license. Examples: As a very simple example, heres how one could use multitask to allow two unrelated tasks to run concurrently: >>> def printer(message): ... while True: ... print message ... yield ... >>> multitask.add(printer(hello)) >>> multitask.add(printer(goodbye)) >>> multitask.run() hello goodbye hello goodbye hello goodbye [and so on ...] For a more useful example, heres how one could implement a multitasking server that can handle multiple concurrent client connections: def listener(sock): while True: conn, address = (yield multitask.accept(sock)) multitask.add(client_handler(conn)) def client_handler(sock): while True: request = (yield multitask.recv(sock, 1024)) if not request: break response = handle_request(request) yield multitask.send(sock, response) multitask.add(listener(sock)) multitask.run() The functions and classes in the multitask module allow tasks to yield for I/O operations on sockets and file descriptors, adding/removing data to/from queues, or sleeping for a specified interval. When yielding, a task can also specify a timeout. If the operation for which the task yielded has not completed after the given number of seconds, the task is restarted, and a Timeout exception is raised at the point of yielding. Tasks can also yield other tasks, which allows for composition of tasks and reuse of existing multitasking code. A child task runs until it either completes or raises an exception, and its output or exception is propagated to its parent. For example: >>> def parent(): ... try: ... print good child says: %s % (yield child()) ... print bad child says: %s % (yield child(bad=True)) ... except Exception, e: ... print caught exception: %s % e ... >>> def child(bad=False): ... if bad: ... raise RuntimeError(oops!) ... yield Hi, Mom! ... >>> multitask.add(parent()) >>> multitask.run() good child says: Hi, Mom! caught exception: oops!.

Requirements: No special requirements
Platforms: Linux
Keyword: Child Cooperative Multitasking Multitask Multitasking Networking Python Programs System Task Tasks Yield
Users rating: 0/10

License: Freeware Size: 10.24 KB
USER REVIEWS
More Reviews or Write Review


MULTITASK RELATED
Libraries  -  Python Call Graph 0.4.0
Python Call Graph (pycallgraph) is a Python library that creates call graphs for Python programs pycallgraph is quite new. It seems to work well and I will most likely improve it in the near future!. Gravit is a free gravity simulator.
4.1 KB  
Science  -  IVuPy 0.1
IVuPy (I-View-Py) aims to be a solid basis for large Qt based Python programs geared to data analysis and 3D visualization of huge data sets. Python is extended by IVuPy with more than 600 classes of two of the Coin3D C++ class libraries: Coin...
1.2 MB  
Audio Tools  -  pymad 0.5.4
pymad is a Python module that allows Python programs to use the MPEG Audio Decoder library. pymad provides a high-level API, similar to the pyogg module, which makes reading PCM data from MPEG audio streams a piece of cake. Using pymad is as...
21.5 KB  
Bug Trackers  -  import_checker 1.1
import_checker checks Python programs for circular (or recursive) imports. Python is a fine programming language. There is one horrendous thing with it though, that bites even the most experienced python programmers every now and then: the scope...
9.22 KB  
Utilities  -  Pyana 0.9.2
Pyana is a extension module that allows Python programs to interface with the Apache Software Foundation's Xalan XSLT transformation engine.
102.4 KB  
Development Editors  -  PyNewton 0.6
PyNewton provides an object oriented binding to access the Newton Game Dynamics engine from Python programs
737.28 KB  
Development Editors  -  Proctor 0.7
Proctor is a tool for running unit tests for Python programs. It uses the standard unittest module, and provides a GUI and command line interface for finding and running all tests available in a package or set of packages.
40.96 KB  
Libraries  -  N:PyTpl 0.5.1
N:PyTpl comes from Necs Python Template System and is a template script written in Python. It parses template files and creates e.g. HTML as output. Therefore, it is ideal to use for HTML pages, because it reduces redundancy to an absolute...
10.24 KB  
Miscellaneous  -  Missed SIGINT in multithreaded programs 1.0
Multithreaded Python programs often ignore the SIGINT generated by a Keyboard Interrupt, especially if the thread that gets the signal is waiting or sleeping. This module provides a workaround by forking a child process that executes the rest of...
 
Bug Trackers  -  Python logging module 0.4.9.5
The Python logging module implements a standard logging system for Python programs. It was strongly influenced by log4j from the Apache project. As this package is included in versions 2.3 and later, only users of earlier versions of Python...
92.16 KB  
NEW DOWNLOADS IN NETWORK & INTERNET, NETWORKING TOOLS
Network & Internet  -  Free WiFi Hotspot 3.3.1
Free WiFi Hotspot is a super easy solution to turn your laptop or notebook into a portable Wi-Fi hotspot, wirelessly sharing your internet connections like DSL, Cable, Bluetooth, Mobile Broadband Card, Dial-Up, etc. through the built-in wireless...
1.04 MB  
Network & Internet  -  Easy Uploads 1.8
Easy uploads is a file storage media streaming application designed by Filestreamers that allows you to upload, store, and stream your files from their virtually unlimited file storage server. Easy Uploads can backup,share, and stream your files...
615.97 KB  
Network & Internet  -  IPv6 CARE 3.2b
IPv6 CARE, "IPv6 Compliant Automatic Runtime Environment", is a Linux tool able to patch ipv6-agnostic programs on-the-fly ('patch' mode). It can also generate a diagnosis about the IPv6 compliance of an application ('check' mode).
409.6 KB  
Network & Internet  -  PacketFence ZEN 3.1.0
PacketFence is a fully supported, trusted, Free and Open Source network access control (NAC) system. Boosting an impressive feature set including a captive-portal for registration and remediation, centralized wired and wireless management, 802.1X...
1024 MB  
Network & Internet  -  django-dbstorage 1.3
A Django file storage backend for files in the database.
10.24 KB  
Networking Tools  -  gvrpad 0.1
gvrpad is a daemon that makes GVRP announcements of all VLAN interfaces on a FreeBSD system. GVRP is the GARP VLAN Registration Protocol, defined in IEEE 802.1Q (VLANS); GARP is the Generic Attribute Registration Protocol, defined in 802.1D...
15.36 KB  
Networking Tools  -  Cheops 0.61
Cheops is an Open Source Network User Interface. It is designed to be the network equivalent of a swiss-army knife, unifying your network utilities. Cheops is for the network what a file manager is for your filesystem..
317.44 KB  
Networking Tools  -  dynacc 0.5.0
Dynacc aims to be a Pakage which gives you control other your Internet Connection. It runs a linux router/host which provides MASQ services and HTTP proxying for a LAN. It gives you the Power to define users/groups which are allowed to make...
122.88 KB  
Networking Tools  -  ssh tunnel on demand 1.0
ssh tunnel on demand provides a script that creates an SSH tunnel on demand. ssh tunnel on demand is a script that makes it possible for a user to create an SSH tunnel to a server and connect to it without needing an account on the box or any...
13.31 KB  
Networking Tools  -  strongSwan 4.1.5
strongSwan is an OpenSource IPsec implementation for the Linux operating system. strongSwan is an OpenSource IPsec implementation for the Linux operating system. In order to have a stable IPsec platform to base our future extensions of the X.509...
1.7 MB