Giter Club home page Giter Club logo

Comments (8)

tmokmss avatar tmokmss commented on May 14, 2024 1

If we want to achieve the below behavior, how about this code?

the client pulls the current active loop or creates a new one.

            try:
                self.loop: AbstractEventLoop = asyncio.get_running_loop()
            except RuntimeError:
                # if there is no running loop, create a new event loop
                self.loop: AbstractEventLoop = asyncio.new_event_loop()

I guess no event loop is set by default for a new thread.

Also note that starting from python 3.10, get_event_loop becomes deprecated and it will be identical with get_running_loop (doc)

from tiktoklive.

isaackogan avatar isaackogan commented on May 14, 2024 1

For sure! The server can handle a few hundred requests a second before I'd need to up the capacity, which will never happen. Just don't want TikTok to tighten security again because the library is used for spam!

Thanks for the help, enjoy the new version!
Isaac

from tiktoklive.

isaackogan avatar isaackogan commented on May 14, 2024

Current Behaviour

It's interesting because it works in the main thread, but not in new threads. I do not know why this is. More than likely I misunderstood the use of get_event_loop

from tiktoklive.

isaackogan avatar isaackogan commented on May 14, 2024

If we want to achieve the below behavior, how about this code?

the client pulls the current active loop or creates a new one.

            try:
                self.loop: AbstractEventLoop = asyncio.get_running_loop()
            except RuntimeError:
                # if there is no running loop, create a new event loop
                self.loop: AbstractEventLoop = asyncio.new_event_loop()

I guess no event loop is set by default for a new thread.

Also note that starting from python 3.10, get_event_loop becomes deprecated and it will be identical with get_running_loop (doc)

Looks good. Do you want to make a pull request? If not, I will when I have a bit of free time next.

My job can betime consuming. Plus, 'twas your find :)

from tiktoklive.

tmokmss avatar tmokmss commented on May 14, 2024

@isaackogan Hi thanks for the offer. I submitted a PR for this. Hope you can check it when you get a chance πŸ™ .

from tiktoklive.

isaackogan avatar isaackogan commented on May 14, 2024

Tested locally in 3.8, looks good. Merged into master and will be released in today's update

from tiktoklive.

isaackogan avatar isaackogan commented on May 14, 2024

One comment, @tmokmss

If your intention is to run multiple clients, there's an IP rate limit for signing connections to respect fair use of TikTok services.

There are a million different reasons to thread, so I won't presume that's why you want to, but, just in-case you wanted to set up a bunch of clients at once, you will need an API key.

Thanks for the contribution, releasing the update now!

from tiktoklive.

tmokmss avatar tmokmss commented on May 14, 2024

New API key feature? Sounds cool, thanks!
I'm currently using it in my small hobby project (hoping it is not harming your server πŸ™ ) but I'll definitely contact you when I need larger-scale access.

from tiktoklive.

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.