async await – Adding websocket functionality to send live data from a Python script. Any edge-cases or unexpected consequences to beware of?

I’m not familiar with how websocket works, but from your code I think I can infer it. So here a few comments:

It seems your subscribers list depends on currently opened connections. That is bad practise. The first reason being, HTTP sessions have a timeout. Hence, after a while (I think its a couple of minutes), you will lose connection to your subscribers. Keeping the connection open, you are also wasting resources, as you don’t really need a connection until you are about to send something.

Also, it seems you are only removing a subscriber from the list if the connection closes correctly. However, what happens it the connection is closed unexpectedly? Instead, you should have caught ConnectionClosed exception.

To solve both these issues, you could have your subscribers be web servers. To subscribe, they would send the server a message with a url to which send the data (and the close the connection), and the server would send them the data when available. Then, the subscribers could send another message to be unsubscribed.

Now, regarthing the second question, both lines of code would have the same behaviour as mirror_ticks has an infinite loop. Hence, no matter if you wait for it to finish, it never will

dnd 5e – What are the edge-cases for the Arcane Gate spell?

Can the portal be facing up/down

This depends on the definition of “the ground”. 5e uses typical terms in English, unless they are they are specifically given other meaning as game terms of art. In English, “the ground” is a relative term, since what is clearly ground to a giant might not be ground to a tiny bug. However, this would make the spell work awkwardly for different size classes; we already know it is 10ft in diameter. I would instead say ground is specifically anything which, as of very recently, counted as a hex or square on which a Medium creature could stand on in the presence of gravity (including with Spider Climb whether active or not). The ground would probably include any detritus which would make it be considered Difficult Terrain. For example:

  • The rubble staircase of a flying ruined castle would be ‘ground’ (even though it isn’t perfectly flat, it is equivalent to a hill; it has protrusions because it has a bunch of stones; it is wood and not earth and that is fine).
  • However furniture and desks (especially if they have function are are searchable) would not count since they are separate items (unless the GM is treating them as Difficult Terrain).
  • Vehicles are a bit ambiguous, but any vehicle which is treated as a hex/square you can stand on (e.g. not horses, ambiguously chariots) should probably count, like giving the command word to a Folding Boat then (because you are >500ft or somesuch) take an action to summon an Arcane Gate on it should be fine.
  • It is ambiguous what happens to the portal if the ground suddenly disappears (if it is destroyed suddenly by the DM in some way in an epic destructive event); obviously the DM may then adjudicate.
    Consequently: a portal may be at weird angles, and almost entirely flat or even sticking into the ground, if there exists sufficiently large rubble (e.g. bricks, small boulders, etc.) to change the normal surface over a few inches. Or just stick it on a wall (but not a curtain, since it’s too flimsy to hypothetically stand on). Otherwise in a flat hallway, the portal would be sticking straight up.

How do the portal interact with ‘physics’; you can obviously harness energy from it, but what else can you do?

Well, the DM should confirm if you can harness energy from it; I’d say yes. For example, if you pipes a river up an incline, it would start to rush faster and faster and faster and faster……. The only reason this wouldn’t work is if the DM wanted to have portals in their world try to harmonize with the laws of physics by being limited by the amount of energy they can transfer (portal starts with energy reserve; transferring people uphill debits costs energy; teleporting downhill gives energy back to the portal).

That said, now one could make someone trivially reach terminal velocity. A portal would not care about the speed at which you enter it perhaps, unless your 5e world has some interesting physics-based worldbuilding… thus if you put two flat portals one-above-the-other, the person would keep falling (teleporting) and falling (teleporting) and falling… and reach terminal velocity within 1rnd if they couldn’t make an athletics check to grab onto the sides (though there might be repeated attempts to do this, as it is equivalent almost to falling off a many-story building).

What if there is insufficient room for the portal?

It is definitely the case that “If the portal would open in the space occupied by a creature, the spell fails, and the casting is lost.” One one hand… this only mentions creatures; on the other hand, this precedent implies maybe one can’t open a portal in a narrow hallway. I feel the DM should make a ruling (ideally before it comes up in practice). In general, AoE casting rules generally specify that cylinder-type things spread out maximally from the center on each end, as if spokes on a bicycle, until a spoke hits something and stops (and the other spokes keep going until the radius is hit, so you might have a cylinder spell that is C-shaped because a tree inside the cylinder provides total cover)… but this seems like a special case where the 10ft portal is in fact a special thing that would violate these rules (unless you consider the portal a wormhole cylinder).

What happens if the portals intersect
What happens if a creature has trouble entering or exiting

What are we talking about here? Let’s illustrate with a small tangent first: Imagine the portals are facing each other in a ‘trap’ (so from the outside or ‘back’, they appear invisible as in the spell text).

narrow corridor: ::::|<-:::->|:::::

The arrows indicate the direction one may enter the portal. Clearly if this was a ‘real’ physical situation like a StarGate(tm), a creature would enter from the left side through the leftmost portal (which is invisible from the left, according to the spell’s wording). Once it passes through, it is stuck in a trap that it cannot escape, assuming the corridor is perfectly a 10ft-diameter circle. (If you open it in a bigger corridor, then the creature might be able to Squeeze by.)

What happens if the gates are placed extremely close together? There are two ways to model the gate:

  1. “linked doorways” scenario — If a creature sticks its arm through and the portal powers off, and the creature doesn’t make a check of some sort, the creature loses its arm. If this was the case, an oversized vehicle would merely not pass through (and would experience really painful sheer forces if it was going in at high speed). In this scenario, a creature could ‘feel’ through to the other side, and might be unable to move through if there was something blocking the exit portal (DM might rule differently for enemy creatures blocking the portal, since that kind of blocking is somewhat different than physical blocking).
  2. “infinite repeated teleports” — If a creature sticks its arm through, nothing happens; either the entire creature goes through (moves into the next space), or the entire creature does not. The Arcane Gate rings are specifically filled with mist, so the DM must decide how the gates function: does stepping through merely cast something like a Dimension Door spell for each thing that goes through, or are the two areas linked in spacetime (sort of like case #1), and merely covered with mist. The flavoring seems to imply the former, but this is probably up to the DM. This scenario may give rise to some funny edge cases, depending on whether the DM rules the edges of the portal are solid or not… if not, then a vehicle might pass through while its passengers might teleport (perhaps desirable).

Thus going back to the modified situation where the portals are facing each other, but squeezed really tight together e.g. <2ft: narrow corridor: ::::||:::::. In case #1 (“linked doorways”), it has put part of its body through an invisible finger-trap (the first gate). Does the creature run through its own organs if it continues?

Consider that in D&D 5e, no spells really affect the insides of a creature’s body. You can’t summon icicles into an enemy’s brain, or teleport the dragon’s heart outside its body (except necromancy and some other schools). Thus (unless your DM says otherwise) it would be quite against the spirit of the system (and also quite broken) if this was an insta-kill. However, this doesn’t mean that 5e doesn’t account for this kind of aggravated / internal damage.

  • Dimension Door: “If you would arrive in a place already occupied by an object or a creature, you and any creature traveling with you each take 4d6 force damage, and the spell fails to Teleport you.”
  • Teleport: “Mishap: The spell’s unpredictable magic results in a difficult journey. Each teleporting creature (or the target object) takes 3d10 force damage and the DM rerolls on the table to see where you wind up (multiple Mishaps can occur, dealing damage each time).” (in 3.5e, this explicitly said you were “scrambled”)

(This would also be 5e’s answer to the ladder paradox.)

If the DM rules that Arcane Gate works like in case #1 (linked doorways), then the teleporting creature would take failed-teleport ‘scramble’ damage (it would not take it twice; typically only teleporting creatures take damage, not whoever they’re teleporting onto), and either fail to teleport, or randomly teleport to somewhere adjacent or fairly close. A DM might possibly rule you may escape the trap by taking this damage.

The full ‘algorithm’ would be as follows:

  • If the creature tries to move through, it will be able to feel the other side (and be blocked by an enemy NPC (possibly), or by a wall, on the other side).
  • If the gate is set up in a trap overlapping the creature, then if the creature tries to move through itself anyway (if it isn’t paying attention…), it probably takes “scramble” damage as above and may probably leave the way it came.
  • Spells (which don’t have “that you can see” wording) may possibly be cast through the gate, subject to DM discretion.

If it’s case #2 (infinite repeated teleports), in the trap scenario, then the creature would fail to teleport, because there is no space on the other side (it is blocking itself), so would just pass through the portal. Alternatively, the DM might rule that the creature does not block itself (so it would be stuck in an infinite teleport loop that it could trivially escape from).

  • If the creature tries to move through, one of three things will happen:
    • If there is a large physical obstruction, it will take “scramble” damage, and either fail to teleport or succeed. DM might instead say scramble damage does not exist and the portal just fails to work.
    • If there is a hostile creature blocking the other it, it might take “scramble” damage, and either fail to teleport or succeed. DM might alternatively say scramble damage does not exist and th portal just fails to work (or works and shunts you to a nearby square as you tumble across the enemy square).
    • If the teleporting creature itself is on the other side, it will just teleport constantly (but can exit the trap without damage), or DM might alternatively say nothing will happen and it can just move through the portals.
  • Spells may not be cast through this.

Can a portal up against a wall rotate to be flush with the wall?

For consistency, the answer should be “yes it can” if the DM allows portals in small corridors (which opens up weird scenarios, e.g. Arcane Gate-teleporting Tiny creatures having great advantage if they can make Tiny portals by intersecting them with walls). The answer should be “no it can’t, without winking out of existince” if the DM disallows portals if there is insufficient room.

If you partially walk through a gate in the backwards direction, can you ‘back out’ in the direction you came from?

Yes in scenario #2, not without scramble damage in scenario #1.

(Comments to this answer are welcome. Rather than give specific rulings, I generally try to give possible sets of possible rulings which are self-consistent.)