When calling the word_segment function from multiple threads, my service sometimes encounters the following exception:
"/usr/local/lib/python3.9/concurrent/futures/_base.py", line 609, in result_iterator ││ yield fs.pop().result() ││ File "/usr/local/lib/python3.9/concurrent/futures/_base.py", line 446, in result ││ return self.__get_result() ││ File "/usr/local/lib/python3.9/concurrent/futures/_base.py", line 391, in __get_result ││ raise self._exception ││ File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run │
│ result = self.fn(*self.args, **self.kwargs) │
│ File "/usr/local/lib/python3.9/site-packages/py_vncorenlp/vncorenlp.py", line 95, in word_segment │
│ self.model.annotate(annotation) │
│ File "jnius/jnius_export_class.pxi", line 878, in jnius.JavaMethod.__call__ │
│ File "jnius/jnius_export_class.pxi", line 972, in jnius.JavaMethod.call_method │
│ File "jnius/jnius_utils.pxi", line 79, in jnius.check_exception │
│ jnius.JavaException: JVM exception occurred: java.util.ConcurrentModificationException
Here is my code to call the word_segment function:
@ducanh997 I ran your code and I saw some different results (compared to running the vanilla rdrsegmenter.word_segment ). Maybe due to thread-safe problem of VnCoreNLP ?
When calling the word_segment function from multiple threads, my service sometimes encounters the following exception:
Here is my code to call the word_segment function:
So my question is whether this library is thread-safe or not. Note that this exception does not always occur, only occasionally.