Python Forum
Python code won't execute from the first line to the bottom
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python code won't execute from the first line to the bottom
#1
I'm having a hard time figuring out what is happening with this code:

print("Starting...")
import os, signal
import json
import zmq
from time import sleep

context = zmq.Context()
context = zmq.Context()
socket = context.socket(zmq.PUB)
socket.bind("tcp://*:5563")


def check_kill_process(pstring):
    for line in os.popen("ps ax | grep " + pstring + " | grep -v grep"):
        fields = line.split()
        pid = fields[0]
        os.kill(int(pid), signal.SIGKILL)

sleep(6)
If I run this in my docker container, it outputs "Starting..." immediately after I run the code, and then exists after 6 seconds.

However, if I run this inside the same docker container but started by docker-compose, it does the following:

after I start docker-compose, it waits 6 seconds and then prints "Starting..."

It's the same container, but one is called directly from the terminal, and the other is called by docker-compose. Could somebody help me debug this process? The container is running ubuntu 16.04, python 3.5 I guess.
Reply


Messages In This Thread
Python code won't execute from the first line to the bottom - by guerlando - Dec-19-2017, 11:30 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Unable to understand the meaning of the line of code. jahuja73 0 362 Jan-23-2024, 05:09 AM
Last Post: jahuja73
  matplotlib x-axis text move bottom upward jacklee26 3 1,087 May-31-2023, 04:28 AM
Last Post: jacklee26
  Trying to loop through code to plot seaborn line plots across multiple subplots eyavuz21 0 1,759 Dec-05-2022, 10:46 AM
Last Post: eyavuz21
  python-docx regex : Browse the found words in turn from top to bottom Tmagpy 0 1,583 Jun-27-2022, 08:45 AM
Last Post: Tmagpy
  Can a program execute code in iPython shell and get result? deanhystad 3 1,806 Jun-17-2022, 03:45 AM
Last Post: Larz60+
  How To Set Up And Execute A Python File knight2000 4 2,027 May-31-2022, 10:02 AM
Last Post: Larz60+
  Python code to read second line from CSV files and create a master CSV file sh1704 1 2,458 Feb-13-2022, 07:13 PM
Last Post: menator01
  multi-line CMD in one-line python kucingkembar 5 4,148 Jan-01-2022, 12:45 PM
Last Post: kucingkembar
  execute python script guy7200 1 1,631 Oct-25-2021, 09:55 PM
Last Post: Axel_Erfurt
  how long can a line of code be? Skaperen 2 2,256 Jun-09-2021, 06:31 PM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020