Python 7.0pl5 Manual de usuario Pagina 27

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 124
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 26
Scheduling a Job
27
All that is occuring here is that when the "cancel()" member function is called, a flag is set. When
the job is executed it will note that the flag is set and will not execute the callback function. If the call-
back function is a member function of a class, it is important to ensure that any reference to the instance
of the Job class is destroyed when no longer required. If this is not done and the reference is a member
variable of the same class the callback function is a member of, a circular reference will exist and that
instance of the class will not be able to be destroyed.
Any arguments to be passed to the callback function would by default be supplied when the instance
of the Job class is created. If it is necessary to generate an instance of the Job class such that it can
be passed to another part of the program, but the arguments to the callback function are not known at
that time, it is instead possible to supply the arguments at the time the job is scheduled. This is done
by using the "schedule()" member function of the Job class rather than that of the dispatcher. Any
arguments supplied in this way will override those provided when the instance of the Job class is cre-
ated.
job = None
def callback1(message):
print message
job.schedule(netsvc.STANDARD_JOB,("override",))
def callback2(message)
print message
job = netsvc.Job(callback1,("default",))
job.schedule(netsvc.STANDARD_JOB)
job = netsvc.Job(callback2)
This would allow for instance a class which accepts callback registrations to return a reference to a
Job class which will later be used to schedule the callback with an as yet undetermined set of argu-
ments. The client who registered the callback could however cancel execution of the callback before
it is called.
Once "cancel()" has been called on an instance of a Job class, whether or not it has already been
scheduled, the callback function will never be executed. To reset the flag which makes the callback
function runnable, the "reset()" member function should be called. To determine if the an instance
of the Job class is still in a runnable state, a truth test can be performed on it.
if job:
# job wasn’t cancelled
job.schedule(netsvc.STANDARD_JOB)
else:
# job was cancelled
pass
If you wish to use the Job class separate to the dispatcher, you can trigger execution of the callback
function by calling the "execute()" member function. If any arguments are supplied to the "exe-
Vista de pagina 26
1 2 ... 22 23 24 25 26 27 28 29 30 31 32 ... 123 124

Comentarios a estos manuales

Sin comentarios

Conveyor-technologies SCANNER MOUNT CONVEYORS manuels

Manuels d'utilisation et guides de l'utilisateur pour Équipement Conveyor-technologies SCANNER MOUNT CONVEYORS.
Nous fournissons des manuels en pdf 1 Conveyor-technologies SCANNER MOUNT CONVEYORS à télécharger gratuitement par type de document : Manuel de l'utilisateur






Plus de produits et de manuels pour Équipement Conveyor-technologies

Modèles Type de document
SG-63I Manuel de l'utilisateur   Conveyor Technologies SG-63I User Manual, 1 pages
WU-2.5M-2 Manuel de l'utilisateur   Conveyor Technologies WU-2.5M-2 User Manual [en] , 1 pages
LG-72I-2 Manuel de l'utilisateur   Conveyor Technologies LG-72I-2 User Manual, 1 pages
LG-48I Manuel de l'utilisateur   Conveyor Technologies LG-48I User Manual, 1 pages
FIFO-.6M-21 Manuel de l'utilisateur   Conveyor Technologies FIFO-.6M-21 User Manual, 1 pages
FIFO-.8M-30/60 Manuel de l'utilisateur   Conveyor Technologies FIFO-.8M-30/60 User Manual [en] , 1 pages
FIFO-1.2M-60 Manuel de l'utilisateur   Conveyor Technologies FIFO-1.2M-60 User Manual [en] [es] [fr] , 1 pages
WORKSTATION OPTIONS Manuel de l'utilisateur   Conveyor Technologies WORKSTATION OPTIONS User Manual, 3 pages
SHC-(LENGTH)I Manuel de l'utilisateur   Conveyor Technologies SHC-(LENGTH)I User Manual [en] , 1 pages
TT-30I Manuel de l'utilisateur   Conveyor Technologies TT-30I User Manual, 1 pages
RT/LT-30I Manuel de l'utilisateur   Conveyor Technologies RT/LT-30I User Manual, 1 pages
FL-24I Manuel de l'utilisateur   Conveyor Technologies FL-24I User Manual, 1 pages
BRC-(LENGTH) Manuel de l'utilisateur   Conveyor Technologies BRC-(LENGTH) User Manual [en] , 1 pages
WB(WIDTH)-(LENGTH)-(OPTIONS) Manuel de l'utilisateur   Conveyor Technologies WB(WIDTH)-(LENGTH)-(OPTIONS) User Manual, 1 pages
TLTC-.6M-0/15 Manuel de l'utilisateur   Conveyor Technologies TLTC-.6M-0/15 User Manual, 1 pages
HWO-7F-2 Manuel de l'utilisateur   Conveyor Technologies HWO-7F-2 User Manual [en] , 1 pages
WI-36I Manuel de l'utilisateur   Conveyor Technologies WI-36I User Manual [en] , 1 pages
RVC-1M-3-LT Manuel de l'utilisateur   Conveyor Technologies RVC-1M-3-LT User Manual, 1 pages
WIET-.6M Manuel de l'utilisateur   Conveyor Technologies WIET-.6M User Manual, 1 pages
CW-AOI-1.2M-2/1 Manuel de l'utilisateur   Conveyor Technologies CW-AOI-1.2M-2/1 User Manual [en] , 1 pages