Précédent   Forum du club des développeurs et IT Pro > Autres langages > Python & Zope > Interfaçage autre langage
Interfaçage autre langage Forum d'entraide pour l'interfaçage avec d'autres langages (ctypes, api C, swig, ...)
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 13/06/2012, 15h17   #1
hl037
Invité régulier
 
Léo
Inscription : janvier 2011
Messages : 11
Détails du profil
Informations personnelles :
Nom : Léo

Informations forums :
Inscription : janvier 2011
Messages : 11
Points : 5
Points : 5
Par défaut Killer un sous-interpréteur

Bonjour, J'ai créé une console interactive python qui s'appuie sur PyInterpreterState_New()
puis, je jongle avec des PyThreadState_Swap pour permettre plusieurs "instances" de la console...
ça marche, mais j'ai un p'tit problème : comment pourrais-je faire pour killer un de mes threads si celui-ci ne répond pas? (genre une boucle infinie)

Merci d'avance!
hl037 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/06/2012, 17h28   #2
PauseKawa
Expert Confirmé
 
Avatar de PauseKawa
 
Homme Patrice BLANGARIN
Technicien Help Desk, maintenance, réseau, système et +
Inscription : juin 2006
Messages : 2 650
Détails du profil
Informations personnelles :
Nom : Homme Patrice BLANGARIN
Localisation : France, Hérault (Languedoc Roussillon)

Informations professionnelles :
Activité : Technicien Help Desk, maintenance, réseau, système et +
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : juin 2006
Messages : 2 650
Points : 3 776
Points : 3 776
Bonjour,

Ceci ?
Citation:
void Py_EndInterpreter(PyThreadState *tstate)

Destroy the (sub-)interpreter represented by the given thread state. The given thread state must be the current thread state. See the discussion of thread states below. When the call returns, the current thread state is NULL. All thread states associated with this interpreter are destroyed. (The global interpreter lock must be held before calling this function and is still held when it returns.) Py_Finalize will destroy all sub-interpreters that haven’t been explicitly destroyed at that point.
@+
__________________
Merci d'utiliser le forum pour les questions techniques.
PauseKawa est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/06/2012, 20h22   #3
hl037
Invité régulier
 
Léo
Inscription : janvier 2011
Messages : 11
Détails du profil
Informations personnelles :
Nom : Léo

Informations forums :
Inscription : janvier 2011
Messages : 11
Points : 5
Points : 5
Oui, mais:
"The given thread state must be the current thread state."
...Or moi, ce que j'aimerais, c'est pouvoir killer le thread depuis un autre... un peu comme avec pthread_cancel... mais je doute qu'on puisse avoir accès au thread posix...

...Le but, c'est d'avoir un moyen d'arrêter l'interpréteur si l'utilisateur entre un truc du genre:
while(true):
print("stupide boucle fait tout planter")


(...Bon, après, j'ai toujours la solution d'intercaler avant chaque instruction une fonction de test pour vérifier qu'il n'y a pas de signal d'arrêt, mais ça va ralentir le code python...)
hl037 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 16h14.


 
 
 
 
Partenaires

Hébergement Web