@Code-Apprentice using yield in an async def function creates an asynchronous generator function, just like using yield in a def function creates a generator function.
asynchronous generator functions create asynchronous generators, which have anext, asend and athrow instead of the regular generator methods.
these methods create awaitables. so gen.send(foo) becomes await agen.asend(foo).
@Code-Apprentice unless you write your own event loop, async coroutines work just like regular coroutines. You only to call the a<something> method instead of <something> and await the result.
otherwise, you need to do the await manually -- i.e. use agen.asend(input).__await__.send(signal). The regular event loop ceremony (exhaust the __await__ instead of sending once) applies.
my bad, that's just agen.asend(input).send(signal).
@MisterMiyagi You know an awful lot about async and I know from past discussions that you work with pretty big data sources. I'm curious if you have a cool example of what you're using this for? A lot of data processing would typically go through numpy or pandas, for example, where I'm not sure you'd have any choice about asynchronous functions
None. It's a debugging question with not enough info
I could make it even more complicated by trying to run it from a Flask app; you'd have no way of knowing that I did that if I just posted that line of code, but it will change the relative paths.
@roganjosh ? It's simply a relative path error and user is presumably not running in the directory they expect they are. I wouldn't call print(f'current directory is: {os.getcwd()}')debugging. Do we really need 6779 junky variants on the same thing... seems unnecessary.
@roganjosh I'm not doing any major data analysis these days, but it wasn't ever numpy/pandas to begin with. I'm doing Grid computing for the LHC crowd -- async is really nice for highly concurrent middleware that runs the actual analyses of our end users.
@MikaelKen consider converting your lists to sets beforehand. You currently have some n^2 set creations when n would be enough.
@roganjosh We're also using async for simulating our infrastructure now. This is double-neat because we can run the core components of the real middleware in the simulation.
Kinda. We're working on overlay batch systems, which means we have a broker that deploys brokers on top of other brokers. It makes sense in the context.
I'm just kinda curious about whether I'm missing a trick because I've never been compelled to use async.... but that can easily just come from not knowing its advantages :)
The major appeal is that it is a) highly scalable and b) easier to debug than threads. You really want the latter if most of your work force has no formal programming training.
@TheNamesAlc One of my good friends just watched is, and it's not good at all. I now know the "plot twist" and it makes no sense. Just forewarning you :)
trying to dockerise a flask app (in one docker) and have a celery task executor (in another) in docker-compose. Flask takes a file upload and sends file location to celery.
I'm making my first web scraping project in Python and I need to collect 300+ pages of data. They are all sorted in the same way "https://example.com/?page=0" I need this zero to rise first to 1, then 2, then 3. Can anyone direct me what to look for on Google?
Sounds like you should be looking at extracting elements that either will give you the number of pages so you can loop or elements that contain an href to the following page though @Pijes :)
@wim It uses := to create an expression with non-constant value, exploiting that builtins do not need defining. The first time, bool(id)^1 is bool(<function>)^1 == True ^ 1 == 1 ^ 1 == 0. The asspression then shadows id. The next time, bool(id)^1 is bool(0)^1 == 0 ^ 1 == 1.
How many merges the algorithm would need to apply on a 9 length long list? Is it 9 since the algorithm has to break all the numbers in individual lists (to contain only one element) and then merge them all together, hence 9?
I don't know if my question is confusing, but what I mean is how many merges would the merge sort algorithm need to perform in order to fully sort a 9 in length list containing numbers? Would that be 8 (n - 1), or 9? I'm not quite sure...