Skip to content

$recv(), deasync or similar #25

Open
@lurodrigo

Description

@lurodrigo

Hi! I just wanted to know if a $recv() method, similar to the ones you see in Python's websockets or websocket-client, is on your plans, or some form of dealing with websockets synchronously. I believe getting data from a websockets API and processing it right after, for example, might be a common use case.

In my case, I needed to get data from an external API, but I couldn't make it work synchronously. I implemented a naïve deasync solution: I made the handlers store data at a list() on my R6 class, created a send method that called ws$send(), and looped over Sys.sleep() until my list was updated (or it took too much time). It didn't work. R kept waiting until my method finished and only then ran the handlers (not really an expert here, but I suspect this might have something to do with the way R handles threads). Suggestions for workarounds would be hugely appreciated :)

I just finished writing a small Python class that does the same (using recv()) and, tomorrow, I will try to integrate it with R using reticulate, but maybe there's a better solution.

Anyway, thanks for your attention!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions