How to stop the take method from ending nested streams, to be used with flatten?
Is there some other solution to nested streams? I tried merging fromDiagram without end symbol, but apparently that doesn't work.
I got told that xs.never() is method specifically for this use case, and while I still don't know why fromDiagram would fail, I suppose that is an answer enough.
xs.merge(stream.take(1), xs.never()).map(nestedStream)
Related
Intellij has a really neat feature, that lets me seamlessly extract a block of code into its own method. I can then give this method a nice, descriptive name and move on with life.
However, intellij also tries to find other blocks of code that are similar, and then tries to perusade me that I should also refactor them too, to use this new method its made. And then, when I hit the oddly-named "cancel" button (which implies the whole operation is cancelled, but it's not, it just stops asking about any remaining blocks), it leaves me looking at whatever the block of code it last asked me about.
I really don't like this feature. Here's why: If I'm say comparing two ints - the naming of the code block will depend on the context of those two ints, but intellij will find any comparison between two ints anywhere in that file, and then insist that this is also a candidate for extraction.
Most times it is not, and to make it worse, when I ask intellij to stop it, in a fit of pique, leaves me wherever the last comparison was, so now I have to navigate back to where I was working.
How do I tell intellij just to extract exactly what I selected, and do nothing else?
Please follow/vote/comment the issue created for this usability problem at YouTrack:
https://youtrack.jetbrains.com/issue/IDEA-233201
I'm using tf.io.decode_proto to parse some custom protobufs in a way that can be used inside #tf.functions. This seems to work fine when accessing message fields, but it raises an unknown field error when trying to access something declared as a oneof (not the fields inside it).
Is there any way to get something similar to proto.WhichOneof(oneof_field) using tf.io.decode_proto? If possible I'd rather avoid getting all possible fields inside the oneof and iterating them to see which one (if any) has non-empty data.
I don't know of any workarounds, but a good way to resolve this is to fix the op itself; the error probably comes from here. It's worth filing an issue to see if anyone might be able to help.
I am using AsioOut because need to minimize latency as much as possible. Since I can only run 1 AsioOut at a time, I am using a MixingWaveProvider32 to play back multiple sounds at the same time. The problem I am running into is that I don't know how to properly remove 1 sound without pausing all the others.
I can easily add a new IWaveProvider (AudioFileReader in my case) to the MixingWaveProvider32 by simply adding it as an input stream, but if I try to remove it the same way the audio starts glitching (I think it's looping the last available buffer). I can prevent this by stopping the AsioOut before swapping the sound, but this brings 2 problems:
all other sounds also get stopped
if the sound I am trying to remove already finished on it's own then I get softlocked on AsioOut.Stop() (the method never finishes).
How do I properly remove 1 sound without running into these problems?
I found a solution myself: By running all sounds through a WaveChannel32 before putting them in the MixingWaveProvider32 I can add and remove the sounds at any time without stopping the AsioOut without getting any audio glitches.
I suspect this is a bug in MixingWaveProvider32 due to the combination of WaveBuffer and Array.Clear which can fail to clear enough of the buffer resulting in the glitching sound you describe.
I suggest you try with MixingSampleProvider instead, which is the successor to MixingWaveProvider32
I am working on TI-TM4C129X ARM board and trying to write a LOG mechanism.It works good when I call it from the Tasks although I faced a problem when I called it with a timer.As I understand that, printf like functions works with Hwi and this causes the error. My aim is to format strings together with the operations like sprintf(),vsprintf(),memcpy() and memset(). How can I solve this problem ? Is there any equivalent methods that success sprintf() operation ?
Thanks for your answers,
Best Regards.
It sounds like the printf is the problem, not sprintf. Assuming your Log message uses an interrupt (UARTs do), and your timer is called from an interrupt, then your options are limited.
I would set a flag in the timer that your task code can check, once outside the context of the timer. This flag could indicate one of several messages to print, even include a time stamp if that helps to resort things afterwards, since your printed messages will not be in order.
Or, with SWO output (like the Segger j-link), you should be able to just send the data. But to avoid scrambled sentences, you need to halt interrupts while sending out a debug message, which obviously can affect the real-time behavior.
I'm trying to port pydoctor to twisted.web.template and have hit a pretty basic problem: pydoctor uses epydoc to render docstrings into HTML but I can't see a way to include this HTML in the generated page without escaping. What can I do?
There is, somewhat intentionally, no way to insert HTML into the page without parsing; twisted.web.template is a bit more of a stickler about producing correct output than nevow was.
There are a couple of ways around this.
Ultimately, your HTML is going to some kind of output stream. You could simply insert a renderer that returns a pair of Deferred objects, and does a .write to the underlying stream after the first one fires but before the second. Kind of gross, but it effectively expresses your intent :).
You can simply re-parse the output of epydoc into HTML using XMLString or similar, so that twisted.web.template can write it out correctly. This will "waste" a little bit of CPU, but in my opinion it will be worth it for (A) the stress-test it will give t.w.t and (B) the guarantee - presuming that t.w.t is correct - that it will give you that you're emitting valid HTML.
As I was writing this answer, however, I realized that point 2 isn't generally possible with arbitrary HTML with the current public API of twisted.web.template. Ideally, you could use html5lib to parse this stuff, and then just dump the parsed input into your document tree.
If you don't mind mucking around with private API, you could probably hook up html5lib's SAX support to the internal SAX parser that we use to load templates.
Of course, the real solution is to fix the ticket you already filed, so you don't have to use private API outside of Twisted itself...