MqMsgque PACKAGE - the package-main is a single piece of code evaluated only once at application startup … More...
Functions | |
void | MqMain (void *code) |
Main entrypoint - start the application | |
MqMsgque PACKAGE - the package-main is a single piece of code evaluated only once at application startup …
Example from MyServer.py
→ The package-main configure the factory and start the server.
import sys from pymqmsgque import * # package-item class MyServer(MqContextC): # factory startup def __init__(self, tmpl=None): self.ConfigSetServerSetup(self.ServerSetup) super().__init__(tmpl) # service to serve all incoming requests for token "HLWO" def MyFirstService(self): self.SendSTART() self.SendSTR(self.ReadSTR() + " World") self.SendRETURN() # define a service as link between the token "HLWO" and the callback "MyFirstService" def ServerSetup(self): self.ServiceCreate("HLWO",self.MyFirstService) # package-main if __name__ == "__main__": # create the "MyServer" factory… and the object srv = MqFactoryC.Add(MyServer).New() try: srv.LinkCreate(sys.argv) srv.ProcessEvent(MqWaitOnEventE.FOREVER) except Exception as ex: srv.ErrorCatch(ex) finally: srv.Exit()
void MqMain | ( | void * | code | ) |
Main entrypoint - start the application
Tcl has a special requirement, for every new server-thread a new interpreter is created and
this interpreter source the toplevel file for initialization. This file is set on library startup and
can be changed with MqInitResetArg0. The problem is the server startup code from the toplevel. For internal
purpose this code should only be executed on application-startup (like the C main function)
and not for every thread again.