Comments (2)
Managed to fix this 👍
from hikari.
Reproduced with optimisations introduced in b9d2855 and the following test script.
$ python -m hikari
hikari v2.0.0 HEAD
located at /home/guesswho/code/hikari/hikari
CPython 3.8.3 GCC 10.1.0
Linux z170x 5.4.52-1-MANJARO #1 SMP PREEMPT Thu Jul 16 16:07:11 UTC 2020 x86_64
import asyncio
import logging
import selectors
import hikari.impl.event_manager_base
logging.basicConfig(level="DEBUG")
class FooEvent(hikari.Event):
@property
def app(self) -> hikari.RESTAware:
return NotImplemented
class Dispatcher(hikari.impl.event_manager_base.EventManagerBase):
async def on_foo(self, _, __):
await self.dispatch(FooEvent())
instance = Dispatcher(NotImplemented, None)
async def producer():
i = 0
while True:
# Do a really short sleep, which puts an event on the selector and
# causes a different task to be invoked. Asyncio otherwise appears
# to immediately invoke the same task, meaning we would keep producing
# and never get a chance to consume. This might be a CPython bug, I
# am not sure.
# Note, setting to anything NON ZERO (even 0.0000000001) seems to hide
# this bug, annoyingly.
await asyncio.sleep(0)
i += 1
if not (i % 1000):
print("produced", i)
instance.consume_raw_event(NotImplemented, "FOO", {})
async def consumer():
i = 0
while True:
i += 1
if not (i % 1000):
print("consumed", i)
def pred(curry):
def predicate(event):
nonlocal curry
if curry:
return True
else:
curry = True
return False
await asyncio.gather(
instance.wait_for(FooEvent, timeout=None, predicate=pred(True)),
instance.wait_for(FooEvent, timeout=None, predicate=pred(False)),
instance.wait_for(FooEvent, timeout=None, predicate=pred(True)),
instance.wait_for(FooEvent, timeout=None, predicate=pred(False)),
)
async def runner():
asyncio.create_task(consumer())
asyncio.create_task(producer())
selector = selectors.SelectSelector()
asyncio.set_event_loop(asyncio.SelectorEventLoop(selector))
asyncio.get_event_loop().set_debug(True)
asyncio.get_event_loop().run_until_complete(runner())
asyncio.get_event_loop().run_forever()
from hikari.
Related Issues (20)
- Add startup callback and shutdown callback traits for RESTBot HOT 1
- Forum channels unrecognised HOT 2
- Localization attribute missing for CommandChoice HOT 1
- typing context not exiting after a webhook is called HOT 2
- Asyncio SSLProto error HOT 3
- Add support for comparing roles HOT 1
- Editing the icon of a server fails HOT 1
- Components shutdown before completion of event listeners
- Option to only cache the bot member HOT 1
- Consider removing upper bound constraint on python version HOT 4
- Support editing community features in `edit_guild` endpoint
- Implement monetization
- Implement default select values
- Specialize InteractionCreateEvent
- Consistent BitEnum Naming HOT 1
- Switch to msgspec HOT 4
- Support sending voice messages HOT 2
- Consider using mkdocs material HOT 3
- `Member.joined_at` is now nullable due to breaking API change
- Sync `guilds.GuildFeature` to Official API
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hikari.