Skip to content

Commit 432ff67

Browse files
committed
Correcciones en desarrollo
1 parent b49b7a6 commit 432ff67

3 files changed

Lines changed: 41 additions & 13 deletions

File tree

core/executor.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,10 @@
1414
from typing import Dict, Any
1515

1616
# Use a Manager so queues and shared state can be passed across the worker process.
17-
if multiprocessing.current_process().name == 'MainProcess':
18-
_multiprocessing_manager = multiprocessing.Manager()
19-
input_queue = _multiprocessing_manager.Queue()
20-
gui_queue = _multiprocessing_manager.Queue()
21-
wait_flag = _multiprocessing_manager.Value('b', False)
22-
else:
23-
_multiprocessing_manager = None
24-
input_queue = None
25-
gui_queue = None
26-
wait_flag = None
17+
_multiprocessing_manager = None
18+
input_queue = None
19+
gui_queue = None
20+
wait_flag = None
2721

2822
current_process = None
2923
current_process_lock = threading.Lock()
@@ -43,6 +37,15 @@ def _global_log_worker():
4337
pass
4438
gevent.sleep(0.05)
4539

40+
def _init_multiprocessing():
41+
global _multiprocessing_manager, input_queue, gui_queue, wait_flag
42+
if _multiprocessing_manager is None:
43+
_multiprocessing_manager = multiprocessing.Manager()
44+
input_queue = _multiprocessing_manager.Queue()
45+
gui_queue = _multiprocessing_manager.Queue()
46+
wait_flag = _multiprocessing_manager.Value('b', False)
47+
eel.spawn(_global_log_worker)
48+
4649
if multiprocessing.current_process().name == 'MainProcess':
4750
eel.spawn(_global_log_worker)
4851

@@ -140,6 +143,7 @@ def kill_execution() -> bool:
140143
# EJECUTOR PRINCIPAL
141144
def execute_user_code(code: str, timeout: int = 5) -> Dict[str, Any]:
142145
global current_process
146+
_init_multiprocessing()
143147
result = {'success': False, 'output': '', 'error': ''}
144148

145149
if input_queue is None or gui_queue is None or wait_flag is None or _multiprocessing_manager is None:

main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from tkinter import filedialog
2424
from datetime import datetime
2525
from cryptography.fernet import Fernet
26+
import multiprocessing
2627

2728
#IMPORTACIONES DEL NÚCLEO DE EDUBOT
2829
from core.ml_adapter import Translator, execute_structs
@@ -1070,6 +1071,7 @@ def api_provide_input(user_text):
10701071
# PUNTO DE ENTRADA PRINCIPAL
10711072

10721073
if __name__ == "__main__":
1074+
multiprocessing.freeze_support()
10731075

10741076
try:
10751077
os.chdir(file_handler.BASE_PATH)

web/index.html

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,9 @@
245245
if (node.type === 'py_print' && inputs.length > 0 && !block.content) {
246246
block.content = inputs[0];
247247
}
248-
248+
if (node.type === 'py_loop' && (!block.iterator || block.iterator.trim() === '')) {
249+
block.iterator = 'i';
250+
}
249251
if (CONTAINER_TYPES.includes(node.type)) {
250252
block.body = [];
251253
}
@@ -613,11 +615,20 @@ <h3 className="text-white font-bold text-lg mb-4 flex items-center gap-2">
613615
);
614616

615617
const BaseNode = ({ data, title, icon: Icon, color, children }) => (
616-
<div>
617-
<div className={`forest-node-header ${color} text-white`}><Icon size={16} /><span>{title}</span></div>
618+
<div className={`relative transition-all ${data.error ? 'ring-2 ring-red-500 shadow-[0_0_15px_rgba(239,68,68,0.6)] rounded-lg' : ''}`}>
619+
<div className={`forest-node-header ${color} text-white`}>
620+
<Icon size={16} /><span>{title}</span>
621+
</div>
618622
<div className="forest-node-body">{children}</div>
619623
<Handle type="target" position="left" className="!bg-gray-400 !w-3 !h-3 hover:!bg-white" />
620624
<Handle type="source" position="right" className="!bg-blue-500 !w-3 !h-3 hover:!bg-white" />
625+
626+
{/* Cartelito flotante con el error de sintaxis */}
627+
{data.errorMsg && (
628+
<div className="absolute -bottom-8 left-0 text-red-300 font-bold text-[10px] bg-gray-900 border border-red-500/50 px-2 py-1 rounded z-50 whitespace-nowrap animate-fade-in shadow-lg">
629+
{data.errorMsg}
630+
</div>
631+
)}
621632
</div>
622633
);
623634

@@ -1595,6 +1606,7 @@ <h3 className="text-red-400 font-bold uppercase text-xs mb-3 flex items-center g
15951606
};
15961607

15971608
const runPipeline = async () => {
1609+
clearNodeErrors(); // Limpiamos errores pasados
15981610
setIsExecuting(true);
15991611
setLogs([{ time: new Date().toLocaleTimeString(), msg: "Iniciando Sandbox...", type: 'warn' }]);
16001612
setEdges(eds => eds.map(e => ({ ...e, data: { status: 'active' } })));
@@ -1606,6 +1618,16 @@ <h3 className="text-red-400 font-bold uppercase text-xs mb-3 flex items-center g
16061618
addLog("Ejecución finalizada.", 'success');
16071619
} else {
16081620
addLog(`Error: ${res.error}`, 'error');
1621+
1622+
if (res.error_nodes) {
1623+
setNodes(nds => nds.map(n => {
1624+
const errInfo = res.error_nodes.find(err => err.node_id === n.id);
1625+
if (errInfo) {
1626+
return { ...n, data: { ...n.data, error: true, errorMsg: errInfo.message } };
1627+
}
1628+
return n;
1629+
}));
1630+
}
16091631
}
16101632
}
16111633
} catch (e) {

0 commit comments

Comments
 (0)