multitask 0.2.0
Sponsored Links
multitask 0.2.0 Ranking & Summary
File size:
0.010 MB
Platform:
Any Platform
License:
MIT/X Consortium License
Price:
Downloads:
869
Date added:
2007-06-12
Publisher:
Chris Stawarz
multitask 0.2.0 description
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!
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!
multitask 0.2.0 Screenshot
multitask 0.2.0 Keywords
O
to use
to perform
python programs
cooperative multitasking
Asynchronous I/O
Allows Python
multitask
yield
task
child
tasks
I/O
multitask 0.2.0
Networking
System
Bookmark multitask 0.2.0
multitask 0.2.0 Copyright
WareSeeker periodically updates pricing and software information of multitask 0.2.0 full version from the publisher, so some information may be slightly out-of-date. You should confirm all information before relying on it. Software piracy is theft, Using crack, password, serial numbers, registration codes, key generators is illegal and prevent future development of multitask 0.2.0 Edition. Download links are directly from our publisher sites, torrent files or links from rapidshare.com, yousendit.com or megaupload.com are not allowed
Featured Software
Want to place your software product here?
Please contact us for consideration.
Contact WareSeeker.com
Related Information
taskstream
what are the main tasks that authors do
tasks grade 7 reading 2003 test
task force
listening to conversation tasks
tasksmart
task manager
task force tools
task manager has been disabled by your administrator
multitasker tool
yield house furniture
task manager disabled
how to multitask
high yield savings account
yield spread
multitasking seminars
yield curve
multitasking
Version History
Related Software
i.Task is a small and fast process viewer. Free Download
clive is a command line program that extracts videos from YouTube and Google Video websites. Free Download
MTasker is a two-file C++ library designed to support very simple cooperative multitasking. Free Download
Medley is an audio collection catalogue application. Free Download
hvclock is a dockapp analog clock and calendar application, running under WindowMaker. Free Download
ngrease project is a simple metalanguage for defining new concepts easily on any level. Free Download
Rubilicious project is a set of Del.icio.us bindings for Ruby. Free Download
Tasks is a dynamic hierarchical view of your tasks, scheduling due dates Free Download
Latest Software
Popular Software
Favourite Software