Skip to content

Commit

Permalink
Remove sync support
Browse files Browse the repository at this point in the history
  • Loading branch information
KurimuzonAkuma committed Feb 7, 2025
1 parent 7cf65d7 commit 189e3c3
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 133 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ If you'd like to support my fork, you can consider:
- **Elegant**: Low-level details are abstracted and re-presented in a more convenient way.
- **Fast**: Boosted up by [TgCrypto](https://github.com/pyrogram/tgcrypto), a high-performance cryptography library written in C.
- **Type-hinted**: Types and methods are all type-hinted, enabling excellent editor support.
- **Async**: Fully asynchronous (also usable synchronously if wanted, for convenience).
- **Async**: Fully asynchronous.
- **Powerful**: Full access to Telegram's API to execute any official client action and more.

### Installing
Expand Down
3 changes: 2 additions & 1 deletion pyrogram/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class ContinuePropagation(StopAsyncIteration):

from . import raw, types, filters, handlers, emoji, enums
from .client import Client
from .sync import idle, compose
from .methods.utilities.compose import compose
from .methods.utilities.idle import idle

crypto_executor = ThreadPoolExecutor(1, thread_name_prefix="CryptoWorker")
11 changes: 1 addition & 10 deletions pyrogram/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,15 +360,6 @@ def __init__(

self.loop = asyncio.get_event_loop()

def __enter__(self):
return self.start()

def __exit__(self, *args):
try:
self.stop()
except ConnectionError:
pass

async def __aenter__(self):
return await self.start()

Expand Down Expand Up @@ -1243,7 +1234,7 @@ async def get_file(
def guess_mime_type(self, filename: Union[str, BytesIO]) -> Optional[str]:
if isinstance(filename, BytesIO):
return self.mimetypes.guess_type(filename.name)[0]

return self.mimetypes.guess_type(filename)[0]

def guess_extension(self, mime_type: str) -> Optional[str]:
Expand Down
11 changes: 3 additions & 8 deletions pyrogram/methods/utilities/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ def run(
loop = asyncio.get_event_loop()
run = loop.run_until_complete

if inspect.iscoroutinefunction(self.start):
run(self.start(use_qr=use_qr, except_ids=except_ids))
run(idle())
run(self.stop())
else:
self.start(use_qr=use_qr, except_ids=except_ids)
run(idle())
self.stop()
run(self.start(use_qr=use_qr, except_ids=except_ids))
run(idle())
run(self.stop())
113 changes: 0 additions & 113 deletions pyrogram/sync.py

This file was deleted.

0 comments on commit 189e3c3

Please sign in to comment.