cycls 0.0.2.16__tar.gz → 0.0.2.18__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cycls
3
- Version: 0.0.2.16
3
+ Version: 0.0.2.18
4
4
  Summary: Cycls SDK
5
5
  Author: Mohammed Jamal
6
6
  Author-email: mj@cycls.com
@@ -0,0 +1 @@
1
+ from .cycls import Cycls
@@ -34,7 +34,7 @@ async def create_ssh_tunnel(x,y,z='tuns.sh'):
34
34
  try:
35
35
  async with asyncssh.connect(z,client_keys=[key_path],known_hosts=None) as conn:
36
36
  listener = await conn.forward_remote_port(x, 80, 'localhost', y)
37
- print("✦/✧","tunnel\n")
37
+ print("✦/✧","tunnel | open\n")
38
38
  await listener.wait_closed()
39
39
  except (OSError, asyncssh.Error) as e:
40
40
  print("✦/✧",f"tunnel disconnected: {e}")
@@ -45,14 +45,14 @@ def register(handles, network, url, mode):
45
45
  response = client.post(f"{network}/register", json={"handles":handles, "url":url, "mode":mode})
46
46
  if response.status_code==200:
47
47
  data = (response.json()).get("content")
48
- for i in data:print(f"✦/✧ {i[0]} / {network}/{i[1]}")
48
+ for i in data:print(f"✦/✧ {i[0]} | {network}/{i[1]}")
49
49
  else:
50
50
  print("✦/✧ failed to register ⚠️")
51
51
  except Exception as e:
52
52
  print(f"An error occurred: {e}")
53
53
 
54
54
  async def run_server(x,y):
55
- config = uvicorn.Config(x, host="127.0.0.1", port=y, log_level="error")
55
+ config = uvicorn.Config(x, host="127.0.0.1", port=y, log_level="error") # loop="asyncio"
56
56
  server = uvicorn.Server(config)
57
57
  await server.serve()
58
58
 
@@ -97,19 +97,28 @@ class Cycls:
97
97
  if self.url != "":
98
98
  prod=True
99
99
 
100
- print(f"✦/✧ serving at port: {self.port}")
100
+ print(f"✦/✧ port | {self.port}")
101
101
  if prod:
102
102
  print("✦/✧",f"production mode | url: {self.url}")
103
103
  register(list(self.apps.keys()), self.network, self.url+"/gateway", "prod")
104
104
  else:
105
105
  self.url = f"http://{self.subdomain}-cycls.tuns.sh"
106
- print("✦/✧","development mode")
106
+ print("✦/✧","mode | development")
107
107
  # print("✦/✧",f"url {self.url}")
108
108
  register(list(self.apps.keys()), self.network, self.url+"/gateway", "dev")
109
109
  t1 = asyncio.create_task(create_ssh_tunnel(f"{self.subdomain}-cycls", self.port))
110
110
 
111
111
  t2 = asyncio.create_task(run_server(self.server,self.port))
112
-
113
- await asyncio.gather(t1, t2) if not prod else await asyncio.gather(t2)
112
+
113
+ try:
114
+ if not prod:
115
+ await asyncio.gather(t1, t2)
116
+ else:
117
+ await asyncio.gather(t2)
118
+ except KeyboardInterrupt:
119
+ # print("🔥")
120
+ tasks = asyncio.all_tasks()
121
+ for task in tasks:
122
+ task.cancel()
114
123
 
115
124
  # poetry publish --build
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "cycls"
3
- version = "0.0.2.16"
3
+ version = "0.0.2.18"
4
4
 
5
5
  packages = [{ include = "cycls" }]
6
6
  description = "Cycls SDK"
@@ -1 +0,0 @@
1
- from .cycls import Cycls, Text, Message
File without changes
File without changes