Giter Club home page Giter Club logo

Comments (16)

Yepoleb avatar Yepoleb commented on July 20, 2024 4

Branch is now merged.

from python-a2s.

Yepoleb avatar Yepoleb commented on July 20, 2024 2

Development branch: https://github.com/Yepoleb/python-a2s/tree/async

from python-a2s.

Yepoleb avatar Yepoleb commented on July 20, 2024

I haven't written any async code yet, but I will give it a try soon.

from python-a2s.

Nereg avatar Nereg commented on July 20, 2024

Ok ! If you nedd any help I can help you.

from python-a2s.

InfernalPlacebo avatar InfernalPlacebo commented on July 20, 2024

@Nereg what is it that you're trying to do with this that isn't working due to Async? We use this on our Discord bot just fine as is

server_info = ''
server_players = ''


async def server():
    global server_info
    global server_players
    try:
        server_info = a2s.info(server_address, 1.0)
        server_players = a2s.players(server_address)
        return True
    except:
        return False

from python-a2s.

Yepoleb avatar Yepoleb commented on July 20, 2024

That's just marking a function as async without it actually being async. It still blocks waiting for a server response.

from python-a2s.

Nereg avatar Nereg commented on July 20, 2024

It stoped my bot for a while. I am using discord.py and may be it is their problem or it is my code. But I think I will rewrite this library.

from python-a2s.

Yepoleb avatar Yepoleb commented on July 20, 2024

I'll give it a try as well as soon as I have time. Let's leave this open, because this is still a feature we want to have.

from python-a2s.

iraizo avatar iraizo commented on July 20, 2024

That's just marking a function as async without it actually being async. It still blocks waiting for a server response.

Im having the same issue right now, trying to make a bot with the library, but it just blocks the code, when the server responds it just does nothing and blocks the task, is there a way you could add a timeout parameter or something?

from python-a2s.

Yepoleb avatar Yepoleb commented on July 20, 2024

Just a quick update: I am still working on this, it's just taking me way more time than expected figuring out how to properly do async UDP. But reading docs is my top priority right now and I'm committed to delivering an async implementation soon.

from python-a2s.

iraizo avatar iraizo commented on July 20, 2024

Just a quick update: I am still working on this, it's just taking me way more time than expected figuring out how to properly do async UDP. But reading docs is my top priority right now and I'm committed to delivering an async implementation soon.

I appreciate it

from python-a2s.

Yepoleb avatar Yepoleb commented on July 20, 2024

Feature PR, please leave feedback if you can: #10

from python-a2s.

Nereg avatar Nereg commented on July 20, 2024

In fact I found code that asyncs some method. Here it is :

async def async_a2s_info(addr):
    loop = asyncio.get_event_loop()
    return await loop.run_in_executor(None, a2s.info, addr)

Found here

from python-a2s.

Yepoleb avatar Yepoleb commented on July 20, 2024

Great idea to use the threading integration in asyncio to do this. The new implementation uses coroutines instead of threads though, so it scales much better, because it doesn't flood the OS with threads when mass querying.

from python-a2s.

iraizo avatar iraizo commented on July 20, 2024

Great idea to use the threading integration in asyncio to do this. The new implementation uses coroutines instead of threads though, so it scales much better, because it doesn't flood the OS with threads when mass querying.

Running in executor and using wait for is the perfect solution, tho it’s not really async

from python-a2s.

Nereg avatar Nereg commented on July 20, 2024

Yeah if I will rewrite my code I will be better using not fast solution to async. And thanks you for all your support !

from python-a2s.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.