MCPcopy Index your code
hub / github.com/rawpython/remi / _instance

Method _instance

remi/server.py:364–444  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

362 return vals
363
364 def _instance(self):
365 global clients
366 global runtimeInstances
367 """
368 This method is used to get the Application instance previously created
369 managing on this, it is possible to switch to "single instance for
370 multiple clients" or "multiple instance for multiple clients" execution way
371 """
372
373 self.session = 0
374 #checking previously defined session
375 if 'cookie' in self.headers:
376 self.session = parse_session_cookie(self.headers['cookie'])
377 #if not a valid session id
378 if self.session == None:
379 self.session = 0
380 if not self.session in clients.keys():
381 self.session = 0
382
383 #if no session id
384 if self.session == 0:
385 if self.server.multiple_instance:
386 self.session = int(time.time()*1000)
387 #send session to browser
388 del self.headers['cookie']
389
390 #if the client instance doesn't exist
391 if not(self.session in clients):
392 self.update_interval = self.server.update_interval
393
394 from remi import gui
395
396 head = gui.HEAD(self.server.title)
397 # use the default css, but append a version based on its hash, to stop browser caching
398 head.add_child('internal_css', "<link href='/res:style.css' rel='stylesheet' />\n")
399
400 body = gui.BODY()
401 body.add_class('remi-main')
402 body.onload.connect(self.onload)
403 body.ononline.connect(self.ononline)
404 body.onpagehide.connect(self.onpagehide)
405 body.onpageshow.connect(self.onpageshow)
406 body.onresize.connect(self.onresize)
407
408 self.page = gui.HTML()
409 self.page.add_child('head', head)
410 self.page.add_child('body', body)
411
412 if not hasattr(self, 'websockets'):
413 self.websockets = set()
414
415 self.update_lock = threading.RLock()
416
417 if not hasattr(self, '_need_update_flag'):
418 self._need_update_flag = False
419 self._stop_update_flag = False
420 if self.update_interval > 0:
421 self._update_thread = threading.Thread(target=self._idle_loop)

Callers 2

do_POSTMethod · 0.95
do_GETMethod · 0.95

Calls 7

_net_interface_ipMethod · 0.95
parse_session_cookieFunction · 0.85
add_childMethod · 0.80
add_classMethod · 0.80
connectMethod · 0.80
set_internal_jsMethod · 0.80
startMethod · 0.45

Tested by

no test coverage detected