whitequark[cis] changed the topic of #glasgow to: https://glasgow-embedded.org · digital interface explorer · https://www.crowdsupply.com/1bitsquared/glasgow · code https://github.com/GlasgowEmbedded/glasgow · logs https://libera.catirclogs.org/glasgow · matrix #glasgow-interface-explorer:matrix.org · discord https://1bitsquared.com/pages/chat
redstarcomrade has quit [Read error: Connection reset by peer]
cyborg_ar has quit [Server closed connection]
cyborg_ar has joined #glasgow
redstarcomrade has joined #glasgow
redstarcomrade has quit [Changing host]
redstarcomrade has joined #glasgow
Griwes has quit [Server closed connection]
Griwes has joined #glasgow
skipwich has quit [Remote host closed the connection]
skipwich has joined #glasgow
_whitelogger has joined #glasgow
skipwich has quit [Ping timeout: 256 seconds]
skipwich has joined #glasgow
jfsimon has quit [Remote host closed the connection]
jfsimon has joined #glasgow
jfsimon has quit [Remote host closed the connection]
jfsimon has joined #glasgow
_whitelogger has joined #glasgow
galibert[m] has joined #glasgow
<galibert[m]> Is there an easy way for a script to test whether it's run directly or through glasgow script?
redstarcomrade has quit [Quit: Cya.]
edf0 has quit [Remote host closed the connection]
RaYmAn_ has joined #glasgow
RaYmAn has quit [Ping timeout: 258 seconds]
edf0 has joined #glasgow
<sazzach[m]> Checking if `__name__ == "__main__"` should work
<galibert[m]> Oh yeah, I should have tried that
<galibert[m]> yep, it's "builtins" when in glasgow, perfect, thanks
<sazzach[m]> Nice, no problem!
ossamo[m] has joined #glasgow
<ossamo[m]> Hey there, is there any info about the "hat" board that we can see in the crowdsupply presentation video ? Thank you
<asjackson> ossamo[m]: the PROM addon?
<ossamo[m]> Yes I think so
<ossamo[m]> Is there a link ?
nafod has quit [Ping timeout: 256 seconds]
nafod has joined #glasgow
Griwes has quit [Ping timeout: 258 seconds]
nafod has quit [Ping timeout: 258 seconds]
fibmod has quit [Ping timeout: 258 seconds]
galibert[m] has quit [*.net *.split]
FFY00_ has quit [*.net *.split]
m42uko_ has quit [*.net *.split]
\\ has quit [*.net *.split]
_alice has quit [*.net *.split]
RaYmAn_ has quit [*.net *.split]
lethalbit has quit [*.net *.split]
DX-MON has quit [*.net *.split]
g5pw has quit [*.net *.split]
abby has quit [*.net *.split]
ormiret has quit [*.net *.split]
cyborg_ar has quit [*.net *.split]
jn has quit [*.net *.split]
koolazer has quit [*.net *.split]
Jonimus has quit [*.net *.split]
f_ has quit [*.net *.split]
Xesxen has quit [*.net *.split]
FireFly has quit [*.net *.split]
XgF has quit [*.net *.split]
GNUmoon has quit [*.net *.split]
sugarbeet has quit [*.net *.split]
twix has quit [*.net *.split]
bgamari has quit [*.net *.split]
balrog has quit [*.net *.split]
pie_ has quit [*.net *.split]
Shiz has quit [*.net *.split]
sam_w has quit [*.net *.split]
quantumjump has quit [*.net *.split]
remexre has quit [*.net *.split]
danieli has quit [*.net *.split]
jfsimon has quit [*.net *.split]
Artea has quit [*.net *.split]
Golui has quit [*.net *.split]
tec4 has quit [*.net *.split]
Ekho has quit [*.net *.split]
DragoonAethis has quit [*.net *.split]
esden has quit [*.net *.split]
JimGM0UIN has quit [*.net *.split]
sven has quit [*.net *.split]
Darius has quit [*.net *.split]
ari has quit [*.net *.split]
Emantor has quit [*.net *.split]
n0p has quit [*.net *.split]
alanvgreen has quit [*.net *.split]
Lord_Nightmare has quit [*.net *.split]
flokli has quit [*.net *.split]
mobius has quit [*.net *.split]
puck has quit [*.net *.split]
skipwich has quit [*.net *.split]
unlobito has quit [*.net *.split]
coderobe has quit [*.net *.split]
mal has quit [*.net *.split]
flummer has quit [*.net *.split]
Stary has quit [*.net *.split]
dos has quit [*.net *.split]
_whitenotifier-a has quit [*.net *.split]
Maxxed has quit [*.net *.split]
SophiaNya has quit [*.net *.split]
gruetzkopf has quit [*.net *.split]
joshua_ has quit [*.net *.split]
viskipappa has quit [*.net *.split]
ebb has quit [*.net *.split]
andymandias has quit [*.net *.split]
Fridtjof has quit [*.net *.split]
electronic_eel has quit [*.net *.split]
leper has quit [*.net *.split]
ali_as has quit [*.net *.split]
adamgreig_ has quit [*.net *.split]
lane has quit [*.net *.split]
smkz has quit [*.net *.split]
hl has quit [*.net *.split]
russss has quit [*.net *.split]
uartist has quit [*.net *.split]
ossamo[m] has quit [*.net *.split]
sazzach[m] has quit [*.net *.split]
davidc__ has quit [*.net *.split]
manawyrm has quit [*.net *.split]
dustinm` has quit [*.net *.split]
sorear has quit [*.net *.split]
chipb has quit [*.net *.split]
danderson has quit [*.net *.split]
cr1901 has quit [*.net *.split]
smeding has quit [*.net *.split]
dne has quit [*.net *.split]
feuerrot has quit [*.net *.split]
itsmk has quit [*.net *.split]
nyanotech has quit [*.net *.split]
cyrozap has quit [*.net *.split]
ePirat has quit [*.net *.split]
_catircservices has quit [*.net *.split]
rcombs has quit [*.net *.split]
SnoopJ has quit [*.net *.split]
atomizer has quit [*.net *.split]
jstoker has quit [*.net *.split]
Eli2 has quit [*.net *.split]
pitust has quit [*.net *.split]
Foxyloxy has quit [*.net *.split]
icb has quit [*.net *.split]
hcsch has quit [*.net *.split]
miek has quit [*.net *.split]
dfriehs has quit [*.net *.split]
anuejn has quit [*.net *.split]
vup has quit [*.net *.split]
mats1 has quit [*.net *.split]
tpw_rules has quit [*.net *.split]
asjackson has quit [*.net *.split]
elms has quit [*.net *.split]
ar-jan has quit [*.net *.split]
mwk_ has quit [*.net *.split]
trh has quit [*.net *.split]
jess has quit [*.net *.split]
ChanServ has quit [*.net *.split]
Griwes_ has joined #glasgow
fibmod_ has joined #glasgow
nafod has joined #glasgow
RaYmAn_ has joined #glasgow
ossamo[m] has joined #glasgow
galibert[m] has joined #glasgow
jfsimon has joined #glasgow
skipwich has joined #glasgow
cyborg_ar has joined #glasgow
Darius has joined #glasgow
Artea has joined #glasgow
lethalbit has joined #glasgow
unlobito has joined #glasgow
viskipappa has joined #glasgow
coderobe has joined #glasgow
ebb has joined #glasgow
sazzach[m] has joined #glasgow
DX-MON has joined #glasgow
Golui has joined #glasgow
FFY00_ has joined #glasgow
jn has joined #glasgow
sam_w has joined #glasgow
m42uko_ has joined #glasgow
g5pw has joined #glasgow
\\ has joined #glasgow
_alice has joined #glasgow
davidc__ has joined #glasgow
abby has joined #glasgow
koolazer has joined #glasgow
ormiret has joined #glasgow
ari has joined #glasgow
itsmk has joined #glasgow
Eli2 has joined #glasgow
pitust has joined #glasgow
Jonimus has joined #glasgow
tec4 has joined #glasgow
f_ has joined #glasgow
mal has joined #glasgow
cyrozap has joined #glasgow
nyanotech has joined #glasgow
Ekho has joined #glasgow
flummer has joined #glasgow
DragoonAethis has joined #glasgow
sugarbeet has joined #glasgow
Xesxen has joined #glasgow
esden has joined #glasgow
Emantor has joined #glasgow
quantumjump has joined #glasgow
JimGM0UIN has joined #glasgow
n0p has joined #glasgow
FireFly has joined #glasgow
XgF has joined #glasgow
sven has joined #glasgow
Foxyloxy has joined #glasgow
cr1901 has joined #glasgow
alanvgreen has joined #glasgow
ePirat has joined #glasgow
manawyrm has joined #glasgow
andymandias has joined #glasgow
twix has joined #glasgow
Lord_Nightmare has joined #glasgow
flokli has joined #glasgow
smeding has joined #glasgow
mobius has joined #glasgow
bgamari has joined #glasgow
balrog has joined #glasgow
pie_ has joined #glasgow
Stary has joined #glasgow
Shiz has joined #glasgow
GNUmoon has joined #glasgow
dustinm` has joined #glasgow
dos has joined #glasgow
Fridtjof has joined #glasgow
dne has joined #glasgow
remexre has joined #glasgow
puck has joined #glasgow
danieli has joined #glasgow
electronic_eel has joined #glasgow
feuerrot has joined #glasgow
leper has joined #glasgow
trh has joined #glasgow
ali_as has joined #glasgow
sorear has joined #glasgow
adamgreig_ has joined #glasgow
lane has joined #glasgow
chipb has joined #glasgow
_whitenotifier-a has joined #glasgow
Maxxed has joined #glasgow
SophiaNya has joined #glasgow
smkz has joined #glasgow
gruetzkopf has joined #glasgow
joshua_ has joined #glasgow
hl has joined #glasgow
danderson has joined #glasgow
russss has joined #glasgow
uartist has joined #glasgow
ChanServ has joined #glasgow
jstoker has joined #glasgow
atomizer has joined #glasgow
jess has joined #glasgow
SnoopJ has joined #glasgow
elms has joined #glasgow
ar-jan has joined #glasgow
asjackson has joined #glasgow
tpw_rules has joined #glasgow
mats1 has joined #glasgow
anuejn has joined #glasgow
vup has joined #glasgow
rcombs has joined #glasgow
dfriehs has joined #glasgow
miek has joined #glasgow
hcsch has joined #glasgow
icb has joined #glasgow
_catircservices has joined #glasgow
mwk_ has joined #glasgow
be65da6e451238ff has joined #glasgow
<galibert[m]> looks like it's (almost?) impossible to write a script that can run in both an async and a non-async context
<galibert[m]> you're not allowed to write await when you're not in a non-async function even if you never run the code
zyp[m] has joined #glasgow
<zyp[m]> it's possible, but whether it's feasible/useful depends on what you're trying to do
<zyp[m]> I've e.g. made a python RPC client with pluggable transports; if you give it an async transport, you get an async RPC API, otherwise you get a blocking RPC API
<zyp[m]> the server side in C++ does the same thing; if you give it an async transport, you can write async handlers, otherwise handlers must be blocking
<zyp[m]> for python, the trick is to do something like this: https://github.com/zyp/protonium/blob/main/protonium/python.py#L48
redstarcomrade has joined #glasgow
redstarcomrade has quit [Read error: Connection reset by peer]
trh has quit [Server closed connection]
trh has joined #glasgow
dne has quit [Remote host closed the connection]
dne has joined #glasgow
redstarcomrade has joined #glasgow
<_whitenotifier-a> [glasgow] whitequark synchronize pull request #1008: Update `pdm.min.lock` - https://github.com/GlasgowEmbedded/glasgow/pull/1008
<_whitenotifier-a> [glasgow] github-merge-queue[bot] created branch gh-readonly-queue/main/pr-1008-5c017ed48f5e64c62d1364791ee086b167a2e13c - https://github.com/GlasgowEmbedded/glasgow
redstarcomrade has quit [Read error: Connection reset by peer]
<_whitenotifier-a> [GlasgowEmbedded/glasgow] github-merge-queue[bot] pushed 1 commit to main [+0/-0/±1] https://github.com/GlasgowEmbedded/glasgow/compare/5c017ed48f5e...39655db32435
<_whitenotifier-a> [GlasgowEmbedded/glasgow] github-merge-queue[bot] 39655db - software: update `pdm.min.lock`.
<_whitenotifier-a> [glasgow] github-merge-queue[bot] deleted branch gh-readonly-queue/main/pr-1008-5c017ed48f5e64c62d1364791ee086b167a2e13c - https://github.com/GlasgowEmbedded/glasgow
<_whitenotifier-a> [glasgow] whitequark closed pull request #1008: Update `pdm.min.lock` - https://github.com/GlasgowEmbedded/glasgow/pull/1008
<_whitenotifier-a> [glasgow] whitequark deleted branch update-lockfile - https://github.com/GlasgowEmbedded/glasgow
redstarcomrade has joined #glasgow
redstarcomrade has quit [Read error: Connection reset by peer]
be65da6e451238ff has quit [Quit: WeeChat 4.7.0]
<galibert[m]> zyp: I want is kind of the way around. I have a script that runs a i2s capture in glasgow, which sends some midi stuff, captures, writes the output somewhere and quits. I'd like to have this script, when run outside glasgow, do the midi stuff and quit (no capture, obviously). Technically, in the second case, I choose a different midi port so that it goes to an emulator for comparison
<galibert[m]> * of the other way around.
<galibert[m]> when run from glasgow, you're in an async context. When run from the command line, you're not. But it looks like you're not allowed to writ code that even looks like you're in an async context when you're not, even if you never execute it
<galibert[m]> s/writ/write/
<galibert[m]> e.g. if False: await run() will throw an exception if you're not in an async function
<galibert[m]> but you can't call an async function without awaiting-it
<galibert[m]> and it doesn't look like you can await something without using the await keyword
<tpw_rules> try: next(not_async_i_promise()) \n except StopIteration: pass \n else: raise RuntimeError("promise failed")
<galibert[m]> blink
<tpw_rules> aww that doesn't work they are technically different types now
<galibert[m]> oh, that would have been await-without-await?
<tpw_rules> oh wait per pep 492 next(not_async_i_promise()) should be not_async_i_promise().send(None)
josHua[m] has joined #glasgow
<josHua[m]> yes, you cannot await from a non async context because, under the hood, await actually causes the function you are in to return a promise and a continuation
<galibert[m]> josHua: you missed the if False:
<galibert[m]> you cannot write the keyword async in a non-async context even if you never, ever execute the statement it is in
<galibert[m]> s/write/_write_/, s/async/await/
<josHua[m]> that’s correct
<josHua[m]> await is not a function, it is a structural transformation that happens at a keyword
<galibert[m]> which is my problem. I'm not trying to run async stuff in a non-async context, I'm trying to do different things when I'm in an async context and when I'm not
<tpw_rules> my solution is valid, i can explain it if you like. i don't know if that implies you should use it
<josHua[m]> if await even exists in a function, the function must return a promise no matter what
<josHua[m]> can you be more specific about what exactly you are trying to do? like what call sites you expect to be used from, and how you wish to behave in each case?
<galibert[m]> I expect the script to be used either from glasgow script mumble.py mu or on the command line python mumble.py
<galibert[m]> (mu being my applet)
<josHua[m]> how about having the main case in mumble.py start up an asyncio event loop and call into your async functions, then?
<josHua[m]> s/main/`__main__`/
<galibert[m]> there are a number of tables that are essentially my experiment definition in the script that I want to use in both cases, sending to the real hardware in one case and to an emulator in the other
<galibert[m]> josHua: I tried. I realized I couldn't call the async functions from glasgow, because that requires await which is forbidden when not in glasgow
<josHua[m]> I’m not sure I understand actually what you’re trying to implement. can you pastebin a sketch of the thing that doesn’t work?
<galibert[m]> tpw: your solution somehow doesn't work, the function doesn't run
<galibert[m]> josHua: the problem is around like 93, the if real: there
<galibert[m]> real = in glasgow = in async context
<galibert[m]> I found no way to run the run function
<josHua[m]> I see
<galibert[m]> which still allows me to reach the else: when not in an async context
<josHua[m]> ok, so what you want is to create an asyncio context of your own to run the run function
<galibert[m]> you can't create an asyncio context when you're alrady in one
<josHua[m]> that's correct, but *that* you can do dynamically
<josHua[m]> decide dynamically, even
<galibert[m]> oh?
<galibert[m]> so, I'm in the if real:, I know I'm in an async context, I want to run the run function, but I'm not allowed to use await. What should I do?
<josHua[m]> asyncio.create_task(run())
<zyp[m]> if there is a running event loop, you can use https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.loop.run_until_complete to do a blocking wait on a future
<zyp[m]> s/a/an/, s/running//, s/run_until_complete/run\_until\_complete/
<galibert[m]> josHua: run() doesn't actually run in that case
<galibert[m]> Tried asyncio.get_running_loop().run_until_complete(run())
<galibert[m]> Got RuntimeError: This event loop is already running
<josHua[m]> oh, man, I see what's going on here.
<josHua[m]> that API might be a footgun after all. you might have to have two files for this -- one glasgow entry point, and one non-glasgow entry point.
<galibert[m]> so I end up with three files, great
<galibert[m]> (the entire point being to share the experiment setup)
<josHua[m]> you also can't `return` a promise from the top level, because you can't `return` from the top level, though that would be th eway to get a promise into https://github.com/GlasgowEmbedded/glasgow/blob/39655db324357384fdca0396cc786dc060e11cdd/software/glasgow/applet/__init__.py#L125-L128
<josHua[m]> I think this is arguably a glasgow API bug, and `script`s should optionally have an `async def __glasgow_main__():` or something that they expose into the global namespace that `run_applet` will try to run after first `eval`'ing the script
<josHua[m]> cc: whitequark (@_discord_182174208896401419:catircservices.org)
<galibert[m]> interesting
<galibert[m]> I didn't think it was that deep
Griwes_ is now known as Griwes
redstarcomrade has joined #glasgow
feuerrot has quit [Server closed connection]
feuerrot has joined #glasgow