Error session line number was not unique in database history logging moved to new session

--when input code as follows (Mac OS/python 3.7): import os print('Process (%s) start...' % os.getpid()) pid = os.fork() --here appears the following error: ERROR! Session/line number was n...

@yanzibugui

—when input code as follows (Mac OS/python 3.7):

import os
print(‘Process (%s) start…’ % os.getpid())
pid = os.fork()

—here appears the following error:

ERROR! Session/line number was not unique in database. History logging moved to new session 14

—is there someone can explain it for me? thanks a lot.

@takluyver

After you fork(), you have two IPython processes which try to write your command to the same entry in the history database. It notices the clash, rejects whichever one was second, so that one starts a new history session.

fork() is tricky to use directly; unless you’re sure of what you’re doing with it, it’s often best to use a higher-level library like multiprocessing or subprocess.

@krassowski

I got this message after interrupting multiprocessing (there was also an error of autoreload just before) in JupyterLab. The error persists — with each attempt to execute a command the session number increases but it’s still there (and apparently my commands are not executed). Is there a way to restore variables from the kernel in such a situation?

@Ashka1990

code: help(%)

ERROR! Session/line number was not unique in database. History logging moved to new session 61

Can anyone please explain

@kaliphd

good afternoon will u kindly help in correcting the above error please

@gjain7

code : from lib.data_loaders import make_data_loader

ERROR! Session/line number was not unique in database. History logging moved to new session 73.

Can anyone explain what is the error in this?
And also I am unable to run the corresponding cell sometimes as it takes a lot of time to execute.

@curiale

Hi, I’m facing a similar error when I paste the code into the python console using %cpaste Here is an example that trigger the error:

In [29]: %cpaste
Pasting code; enter '--' alone on the line to stop or use Ctrl-D.
:        lung_exp_warp = utils.image.resample(lung_insp,
                                             lung_exp,
                                             disp2INSP_tx,
                                             is_label=True)
        Im = sit.k.GetArrayFromImage(lung_insp)
        Im_w = sitk.GetArrayFromImage(lung_exp_warp)
:--
ERROR! Session/line number was not unique in database. History logging moved to new session 1116

@jykr

Hi, can someone reopen this issue? (@yanzibugui)

You will get this error if the error occurs within the code that is run in parallel.
An easy workaround will be to check if your script runs without error when you didn’t use multiprocessing (ex. substitute with for loop).

@MrMino

@jykr This is 4 years old. The original issue is not the same as yours. Please open a new thread and put all of the relevant information (Python/IPython version, OS, reproduction, etc.) there.

@ipython
ipython

locked as resolved and limited conversation to collaborators

Jul 27, 2022

yanzibugui

ERROR! Session/line number was not unique in database. History logging moved to new session 14

—when input code as follows (Mac OS/python 3.7):

import os
print(‘Process (%s) start…’ % os.getpid())
pid = os.fork()

—here appears the following error:

ERROR! Session/line number was not unique in database. History logging moved to new session 14

—is there someone can explain it for me? thanks a lot.

takluyver

After you fork(), you have two IPython processes which try to write your command to the same entry in the history database. It notices the clash, rejects whichever one was second, so that one starts a new history session.

fork() is tricky to use directly; unless you’re sure of what you’re doing with it, it’s often best to use a higher-level library like multiprocessing or subprocess.

krassowski

I got this message after interrupting multiprocessing (there was also an error of autoreload just before) in JupyterLab. The error persists — with each attempt to execute a command the session number increases but it’s still there (and apparently my commands are not executed). Is there a way to restore variables from the kernel in such a situation?

Ashka1990

code: help(%)

ERROR! Session/line number was not unique in database. History logging moved to new session 61

Can anyone please explain

kaliphd

good afternoon will u kindly help in correcting the above error please

gjain7

code : from lib.data_loaders import make_data_loader

ERROR! Session/line number was not unique in database. History logging moved to new session 73.

Can anyone explain what is the error in this?
And also I am unable to run the corresponding cell sometimes as it takes a lot of time to execute.

curiale

Hi, I’m facing a similar error when I paste the code into the python console using %cpaste Here is an example that trigger the error:

In [29]: %cpaste
Pasting code; enter '--' alone on the line to stop or use Ctrl-D.
:        lung_exp_warp = utils.image.resample(lung_insp,
                                             lung_exp,
                                             disp2INSP_tx,
                                             is_label=True)
        Im = sit.k.GetArrayFromImage(lung_insp)
        Im_w = sitk.GetArrayFromImage(lung_exp_warp)
:--
ERROR! Session/line number was not unique in database. History logging moved to new session 1116

jykr

Hi, can someone reopen this issue? (@yanzibugui)

You will get this error if the error occurs within the code that is run in parallel.
An easy workaround will be to check if your script runs without error when you didn’t use multiprocessing (ex. substitute with for loop).

MrMino

@jykr This is 4 years old. The original issue is not the same as yours. Please open a new thread and put all of the relevant information (Python/IPython version, OS, reproduction, etc.) there.

Некоторое время я получаю следующую ошибку (предупреждение?):

ERROR! Session/line number was not unique in database. History logging moved to new session

При работе с ноутбуком Jupyter (<XXXX> — это число, например 9149).
Поскольку такая же ошибка была обнаружена для Spyder (Предупреждение Spyder: «Номер сеанса / строки не уникален в базе данных»), я предполагаю, что существует некоторая проблема с журналированием ядра IPython.

Возникает вопрос: может ли быть какая-то связь между запуском моего кода и ошибкой?

Вероятно, ошибка вызвана моим кодом? Я касаюсь IPython API следующим образом:

import IPython 

def beep():
    Python.display.display(IPython.display.Audio(url = "http://www.w3schools.com/html/horse.ogg", autoplay=True))

def play_sound(self, etype, value, tb, tb_offset=None):
    self.showtraceback((etype, value, tb), tb_offset=tb_offset)
    beep()

get_ipython().set_custom_exc((Exception,), play_sound)

Я использую в своем коде функцию beep(). Я также работаю с большими данными, что приводит к исключениям MemoryError.

И что еще более важно, может ли ошибка повлиять на поведение моего кода (учитывая, что я не пытаюсь получить доступ к журналам)?

[РЕДАКТИРОВАТЬ]
Кажется, проблема отличается от Предупреждение Spyder: «Номер сеанса / строки не уникален в базе данных», поскольку я могу воспроизвести ее с помощью Jupyter Notebook, но не с помощью Spyder.


abukaj, 16 мая 2018 г., 13:39

10

7 437

3


Ответы:

Решено

Это только частичный ответ — награда по-прежнему имеет право на участие.

Ошибка действительно зависит от моего кода — по крайней мере, когда есть SyntaxError.

Я воспроизвел его с тремя следующими клетками.

In [31]: print(1)
         1

In [31]: print 2
           File "<ipython-input-32-9d8034018fb9>", line 1
             print 2
                   ^
         SyntaxError: Missing parentheses in call to 'print'

In [32]: print(2)
         2
         ERROR! Session/line number was not unique in database. History logging moved to new session 7

Как видите, счетчик строк во второй ячейке не увеличился (из-за проблем с синтаксисом).

Вдохновленный комментарием @zwer, я запросил базу данных $HOME/.ipython/profile_default/history.sqlite:

sqlite> select session, line, source from history where line > 30;
6|31|print(1)
6|32|print 2
7|32|print(2)

Понятно, что счетчик строк для второй ячейки увеличен в базе данных, но не в записной книжке.

Таким образом, когда третья ячейка была успешно выполнена, ноутбук попытался сохранить свой источник с той же строкой, что нарушило ограничение PRIMARY KEY:

sqlite> .schema history
CREATE TABLE history
                (session integer, line integer, source text, source_raw text,
                PRIMARY KEY (session, line));

В результате был запущен отказоустойчивый, который выдал предупреждение и создал новый сеанс.

Я предполагаю, что проблема не влияет на поведение моего кода, однако мне не хватает надежного источника для такого утверждения.


abukaj, 23 мая 2018 г., 11:34

Эта проблема возникает в ячейках Блокнот Jupyter, когда ячейки имеют одинаковый номер строки.
Что вы можете сделать — если вы находитесь в Блокнот Jupyter — просто перезапустите ядро.
Ошибка будет решена.


kiran, 10 апреля 2020 г., 07:52

У меня возникла такая же ошибка, когда я пытался запустить некоторый асинхронный код в записной книжке jupyter. Суть была такая (может иметь смысл для тех, кто знаком с asyncio)

cell #1 
output = loop.run_until_complete(future)

cell #2
print(output)

Запустите обе ячейки вместе, и я получу ошибку OP.
Объедините ячейки вместе вот так, и все заработало чисто.

cell #1 
output = loop.run_until_complete(future)
print(output)

JoeyC, 29 октября 2020 г., 06:20

Интересные вопросы для изучения

Понравилась статья? Поделить с друзьями:
  • Error service disabled 0x80070422
  • Error service already exists
  • Error servers l4d2
  • Error server timeout elapsed without receiving a message from the server
  • Error server reached maxclients setting consider raising the maxclients setting