Beispiel #1
0
def workerRun(objClasses, resultContainer, pparam, lockList):
    objHandler = ObjHandler()
    objHandler.loadClasses(objClasses, None)
    from multiprocessing.pool import ThreadPool
    thpool = ThreadPool(len(lockList))
    while 1:
        callId = pparam.recv()
        thpool.apply_async(func=wokerCall,
                           args=(callId, resultContainer, pparam, lockList,
                                 objHandler))
Beispiel #2
0
def initCservice():
    global cservice
    objClasses = [(SampleServerApi, None, {})]

    if workerSize <= 0:
        cservice = ObjHandler()
        cservice.loadClasses(objClasses, None)
    else:
        from server.objhandle import ProcessObjHandler, WorkerScheduler
        ws = WorkerScheduler(objClasses, workerSize, lockSize)
        cservice = ProcessObjHandler(ws)
        cservice.loadClasses(objClasses, None)
Beispiel #3
0
def createCservice(servicePath, cserviceInfo, cserviceProxy, stubFiles, rHandler):
    servicePath = servicePath.strip().lower()
    if servicePath == "":
        servicePath = "cservice"
    if rHandler.handlers.__contains__(servicePath):
        return

    from libs.refrect import DynamicLoader
    ignoreImportExcept = False
    DynamicLoader.getClassFromFile(None, ignoreImportExcept, *stubFiles)

    slog.info("Service: %s" % ", ".join([c[0].__name__ for c in cserviceInfo]))
    cservice = ObjHandler()
    cservice.loadClasses(cserviceInfo, rHandler)

    rHandler.addHandler(servicePath, cservice)
    for cserviceCls, handleUrl in cserviceProxy:
        rHandler.addHandler(handleUrl.lower(), cserviceCls(cservice.objs))