@@ -397,6 +397,11 @@ def get_next(self):
397397 # ... persist event ...
398398 """
399399
400+ # If we have a list of instances that are allowed to write to this
401+ # stream, make sure we're in it.
402+ if self ._writers and self ._instance_name not in self ._writers :
403+ raise Exception ("Tried to allocate stream ID on non-writer" )
404+
400405 return _MultiWriterCtxManager (self )
401406
402407 def get_next_mult (self , n : int ):
@@ -406,6 +411,11 @@ def get_next_mult(self, n: int):
406411 # ... persist events ...
407412 """
408413
414+ # If we have a list of instances that are allowed to write to this
415+ # stream, make sure we're in it.
416+ if self ._writers and self ._instance_name not in self ._writers :
417+ raise Exception ("Tried to allocate stream ID on non-writer" )
418+
409419 return _MultiWriterCtxManager (self , n )
410420
411421 def get_next_txn (self , txn : LoggingTransaction ):
@@ -416,6 +426,11 @@ def get_next_txn(self, txn: LoggingTransaction):
416426 # ... persist event ...
417427 """
418428
429+ # If we have a list of instances that are allowed to write to this
430+ # stream, make sure we're in it.
431+ if self ._writers and self ._instance_name not in self ._writers :
432+ raise Exception ("Tried to allocate stream ID on non-writer" )
433+
419434 next_id = self ._load_next_id_txn (txn )
420435
421436 with self ._lock :
0 commit comments