A package that streamlines Python threading
Reason this release was yanked:
Does Not Work. Please download from Github
Project description
QUEENBEE THREADING PLATFORM
1 README
1.1 What Is Queenbee?
QUEENBEE IS:
- A threading platform that simplifies threading, written in Python.
- A project by
puzzle00- Your gateway to streamlined threading in Python!
2 DOCUMENTATION
2.1 Overview
2.1.1 Queen Bees {#qb-overview}
Queen Bees (
class QueenBee()) handle the creation of Worker Bees and the storing of Drones (templates for workers.) You generally need one Queen Bee per app. To use a Queen Bee, create one (q=QueenBee()) and callq.makeBee(d.mate())where"d"is a Drone Bee.2.1.2 Drone Bees {#db-overview}
Drone Bees (
class DroneBee(func,**inf)) serve as templates to create Worker Bees. Their constructor is passed a callback to a function (func) and metadata, for example a label for the worker bee type it's representing. You usually have several drones per application.2.1.3 Workers {#wb-overview}
Worker Bees (
class WorkerBee()) handle the actual work defined by the Drone Bees they are linked to. They can be dispatched by a Queen'sbegin()method or (advanced) Queenless Operation.2.2 In Detail
2.2.1 Queen Bees {#qb}
create() : Creates Workers. DO NOT CALL YOURSELF UNLESS USING QUEENLESS OP (ADVANCED)
makeBee(DroneBee d) : Stores a Drone in the drone repo.
begin(label=None) : Starts the Worker Bees. If
labelparam included: starts all the workers with labellabel.uptask(label,cap) : Tasks
capbees with drone (identified by label)label2.2.2 Drone Bees {#db}
__init__(func,allmd=None,**inf) : Initializes the drone with task
funcand info (including label)inf. If you want to pass a dict as metadata, use allmd.mate() : clones the drone! Returns a copy of the drone.
process() : Do not call yourself. Auto-called by the class. Processes the meta-info
infdict.retask(func) : Gives the drone a new task to use. Some info: This is why you always use mate().
2.2.3 Worker Bees {#wb}
go() : DO NOT CALL YOURSELF UNLESS USING QUEENLESS OP (ADVANCED) Do not call yourself. Auto-called by the Queen class. Starts this Worker.
apply(DroneBee d) : DO NOT CALL YOURSELF UNLESS USING QUEENLESS OP (ADVANCED) Do not call yourself. Auto-called by the Queen class. Set this worker to a certain Drone type.
2.2.4 Other Classes
BeeBuffer : BeeBuffer is the class that queues the bees while waiting for a turn to run.
2.3 Queenless Op (Advanced) {#qo}
note: this is an advanced topic. Recommended for experienced people only.
2.3.1 Overview
Queenless Op is a way you can exert finer control over your Worker Bees by controlling the bees without a queen. note: you still need a queen, the queen just isn't controlling your bees.
2.3.2 In Detail
Making Bees : Instead of letting the queen make worker bees, you create them yourself by using the Queen's
create()method. This will create a blank bee, that you then infuse with a drone using the worker'sapply()method, like this:
q=QueenBee()
def myFunc():
print("Hello World!")
d=DroneBee(myFunc,label="Hello World",tag='test')
emptyBee=QueenBee._create()
emptyBee.apply(d)
emptyBee.go()
Go'ing Bees : To go (start) a bee, call its
go()method. Usually, this method is called by the Queen'sbegin()method, but in QO, it is called by the user.2.4 Examples {#ex}
2.4.1 Bee Hello
A simple example of using queenbee to say hello world. (not something you would usually use qb for)
import queenbee as qb
def hello():
print("Hello World")
q=qb.QueenBee()
d=qb.DroneBee(hello,label="HelloMyBeesHello")
q.makeBee(d.mate())
q.uptask("HelloMyBeesHello",1)
q.begin()
#or: q.begin("HelloMyBeesHello")
###############
#Output: #
# Hello World #
###############
2.4.2 Two Bees
Now something more useful: Two Bees.
import queenbee as qb
def FirstBee():
print(1,end='')
def SecondBee():
print(2,end='')
q=qb.QueenBee()
fb=qb.DroneBee(FirstBee,label='1')
sb=qb.DroneBee(SecondBee,label='2')
q.makeBee(fb.mate())
q.makeBee(sb.mate())
q.uptask('1',1)
q.uptask('2',1)
q.begin()
##############
#Output: #
# 12 or 21 #
##############
2.4.3 Three Bees
you know now!
import queenbee as qb
def b1():
print(1, end='')
def b2():
print(2,end='')
def b3():
print(3,end='')
q=qb.QueenBee()
d1=qb.DroneBee(b1,label='1')
d2=qb.DroneBee(b2,label='2')
d3=qb.DroneBee(b3,label='3')
q.uptask('1',1)
q.uptask('2',1)
q.uptask('3',1)
q.makeBee(d1.mate())
q.makeBee(d2.mate())
q.makeBee(d3.mate())
###################################
#Output: #
# 123, 132, 213, 231, 312, or 321 #
###################################
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file queenbeethreading-1.0.tar.gz.
File metadata
- Download URL: queenbeethreading-1.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e19b3a2cf1c0a53ff5985d4088cd1f8838dd071c691be028deb0cad9aa4e22b
|
|
| MD5 |
6357263af18d450c1ed99fcd65a00de4
|
|
| BLAKE2b-256 |
c9e814abb479d6a449e1eb7e06f393c0a872bc9eabd46a4b22e457af303de65e
|
File details
Details for the file queenbeethreading-1.0-py3-none-any.whl.
File metadata
- Download URL: queenbeethreading-1.0-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
53cc9e1cff8e48ae3de920e44a24dbcebaa3728e08ce348bfba63c977f594397
|
|
| MD5 |
3b565c9459695f8ab24c25e99d27b5c4
|
|
| BLAKE2b-256 |
bb5416b3af0d98ebb38d3dc447a0a5c786bc8c4034b70cdea5010729abab9c72
|