Serial port disabled after serial communication with python

Hi all,
I've an Arduino UNO (i use it with windows xp on COM5) and after a successfully serial communication with python the serial port COM5 is disappeared. Now i post the arduino and python code.
Arduino code:

int ledPin= 13;
int val=0;
char msg=' ';
void setup() {
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
  Serial.print("Program Initiated\n");  
}
void loop() {
  while (Serial.available()>0) {
    msg = Serial.read();
  }
  
  if (msg == 'Y') {
    digitalWrite(ledPin, HIGH);
    Serial.print("HIGH");
    msg=' ';
  } else if (msg == 'N') {
    digitalWrite(ledPin, LOW);
  }
}

Python code:

import serial  
import time  
try:
    arduino = serial.Serial('COM5', 9600)
    time.sleep(3)
    arduino.write('Y')  
    print arduino.readline()
    print arduino.readline() 
except:  
    print "Failed to connect on COM5"
arduino.close()

Thanks in advance

I've an Arduino UNO (i use it with windows xp on COM5) and after a successfully serial communication with python the serial port COM5 is disappeared.

Is disappeared from where?

Opening the serial port resets the Arduino.

    time.sleep(3)

If that's 3 seconds, that's far longer than needed. If that's 3 milliseconds, that's no where near enough time.

Thanks for answer but i've resolved.

time.sleep(3) -> wait 3 seconds