コード例 #1
0
import asyncio
from managers.global_manager import GlobalManager

gm = GlobalManager()
gm.start()


async def main():
    print("hi")
    await gm.discussion_manager.call_test()
    print("bye")


#asyncio.run(main())
if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())
"""
try:
    loop.run_until_complete(asyncio.wait([main()]))
except asyncio.CancelledError:
    print('Tasks has been canceled')
finally:
    loop.close()
"""
コード例 #2
0
ファイル: worker.py プロジェクト: rainflame/pith
async def startup(ctx):
    utils.logging.info("Starting new worker...")
    # dedicate a manager for the worker
    ctx["cursor"] = utils.get_time()
    ctx["manager"] = GlobalManager()
    ctx["manager"].start()  # no Redis
コード例 #3
0
from utils.utils import (
  get_room,
  logger,
  is_error, 
  make_error,
  DictEncoder,
)

from managers.global_manager import GlobalManager
import schema.board_requests as breq
import schema.board_responses as bres
import schema.discussion_requests as dreq
import schema.discussion_responses as dres


gm = GlobalManager()
sio = gm.sio


class GlobalNamespace(AsyncNamespace):

    async def on_create_board(self, sid, request):
        logger.info("Created board...")
        product = gm.create()
        result = dumps(product, cls=DictEncoder)
        logger.info("Created board {}.".format(product["board_id"]))
        return result

sio.register_namespace(GlobalNamespace('/global'))

class BoardNamespace(AsyncNamespace):
コード例 #4
0
ファイル: board_manager_test.py プロジェクト: slz4025/pith
 def setUp(self) -> None:
     gm = GlobalManager()
     gm.start()
     self.board_manager = gm.board_manager
     self.log = logging.getLogger("BoardManagerTest")
コード例 #5
0
"""
Create a fake discussion with a user to begin frontend development.
"""
from managers.global_manager import GlobalManager
from utils import utils

gm = GlobalManager()
gm.start()

gm.boards.delete_many({})
gm.discussions.delete_many({})
gm.units.delete_many({})
gm.links.delete_many({})
gm.transclusions.delete_many({})
gm.unit_updates.delete_many({})
gm.users.delete_many({})

board = gm.create()
board_id = board["board_id"]

print("made board id {}".format(board_id))
コード例 #6
0
 def setUp(self) -> None:
     gm = GlobalManager()
     gm.start()
     self.user_manager = gm.user_manager
     self.log = logging.getLogger("UserManagerTest")