Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use an asynchronous MongoDB client #17

Open
Vibhu-Agarwal opened this issue May 15, 2021 · 0 comments
Open

Use an asynchronous MongoDB client #17

Vibhu-Agarwal opened this issue May 15, 2021 · 0 comments
Labels
help wanted Extra attention is needed

Comments

@Vibhu-Agarwal
Copy link
Contributor

Vibhu-Agarwal commented May 15, 2021

  • Blocking

    Hedwig/messaging.py

    Lines 18 to 21 in 0956cab

    ChatMessage.objects.only("user", "time", "text")
    .raw({"room": BsonObjectID(chat_room_id)})
    .order_by([("time", ASCENDING)])
    .values()
  • Blocking

    Hedwig/main.py

    Line 15 in 0956cab

    chat_room = ChatRoom(**dict(chat_input)).save()
  • Blocking

    Hedwig/db/models.py

    Lines 68 to 70 in 0956cab

    cls.objects.only("title", "admin", "participants", "active")
    .values()
    .get({"_id": BsonObjectID(chat_room_id)})
  • Hack; not natively asynchronous

    Hedwig/messaging.py

    Lines 86 to 91 in 0956cab

    save_chat_msg = sync_to_async(
    ChatMessage(
    user=user_id, room=chat_room_id, text=message.text, time=message.time
    ).save,
    thread_sensitive=True,
    )

motor is asynchronous; pymongo is not

  • pymodm is based on pymongo therefore it's synchronous in nature

👉 Find an ODM library like pymodm which is based on motor and replace pymodm with that

Some ideas:

@Vibhu-Agarwal Vibhu-Agarwal added the help wanted Extra attention is needed label Jul 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant